trim.go 364 B

12345678910111213141516171819202122
  1. package main
  2. import (
  3. "errors"
  4. "fmt"
  5. "os"
  6. "strings"
  7. )
  8. func removeAdvFile(src string) error {
  9. index := strings.Index(src, "static/adv")
  10. if index == -1 {
  11. return errors.New("error src")
  12. }
  13. path := src[index:]
  14. return os.Remove(path)
  15. }
  16. func main() {
  17. err := removeAdvFile("https://wine.ifarmcloud.com/api/static/adv/20230925-test.jpg")
  18. fmt.Println(err)
  19. }