recipes2/internal/lib/stringcv/stringcv.go

19 lines
425 B
Go
Raw Permalink Normal View History

2024-01-21 12:10:06 +02:00
package stringcv
import (
"fmt"
"strings"
)
// GetFilenameFromUrl convert url to filename.
func GetFilenameFromUrl(url string) string {
url_els := strings.Split(url, "/")
return url_els[len(url_els)-1]
}
// RenameFile changes filename.
func RenameFile(old_filename, new_name string) string {
old_file_els := strings.Split(old_filename, ".")
return fmt.Sprintf("%s.%s", new_name, old_file_els[len(old_file_els)-1])
}