初始化

This commit is contained in:
李琦
2026-06-17 08:05:20 +08:00
parent 6dfe73191c
commit fb3d707a32
36 changed files with 7002 additions and 261 deletions

33
services/utils.go Normal file
View File

@@ -0,0 +1,33 @@
package services
import (
"encoding/json"
"path/filepath"
"strings"
)
func GetOutputPath(inputPath, suffix string) string {
ext := filepath.Ext(inputPath)
name := strings.TrimSuffix(inputPath, ext)
return name + suffix + ext
}
func ChangeExtension(filePath, newExt string) string {
ext := filepath.Ext(filePath)
name := strings.TrimSuffix(filePath, ext)
return name + newExt
}
func GetBaseName(filePath string) string {
name := filepath.Base(filePath)
ext := filepath.Ext(name)
return strings.TrimSuffix(name, ext)
}
func ToJSON(v interface{}) ([]byte, error) {
return json.MarshalIndent(v, "", " ")
}
func ParseJSON(data []byte, v interface{}) error {
return json.Unmarshal(data, v)
}