go get github.com/marcellowy/go-common
package main
import (
"fmt"
"github.com/marcellowy/go-common/tools"
)
func main() {
// md5
fmt.Println(tools.Md5("test")) // output: 098f6bcd4621d373cade4e832627b4f6
// file md5
var path = "path/file/test.txt"
hash, err := tools.Md5File(path)
if err!=nil{
// if path not exists or not file
return
}
fmt.Println(hash) // output: hash string
}
package main
import (
"fmt"
"github.com/marcellowy/go-common/tools"
)
func main() {
_ = os.MkdirAll("./test", os.ModePerm)
// copy parent "foo" and all subdirectory and "foo.txt" file to "./test" directory
if err := tools.Copy("./test", []string{"../foo", "../foo.txt"});err!=nil{
// print log
}
// copy file
// copy "b.txt" to "../../a.txt"
if err := tools.CopyFile("../../a.txt", "./b.txt"); err !=nil {
// print log
}
}
- support base64 encode/decode
- only bugfix
- added ftp download/upload/delete
- added download file from URL, support large file
- added func ReCreateDirectory removes the directory at the given path and creates a new empty directory at the same path.
- added func RemoveLastSeparator removes the last separator from the given path string.
- added func Copy copies the contents of the file at the given source path to the destination path.
- added func DirHasPrefix checks if the directory path 's' has a prefix 'prefix'.
- added func CopyFile copies the contents of the file at the given source path to the destination path.
- added func Zip/Unzip zip or unzip file/directory
- added thread safe slice
- added thread safe map/slice unit test case
- bugfix
- remove old version
- fix parse time
- added gogf support
- added auto register router for gin framework, see router/README.md
- added GormLogger help write gorm log to zap log
- bugfix
- add SliceTrimSame remove slice same element
- add SliceRemove remove slice specify element
- RemoveSameFromStringSlice Departed,use SliceTrimSame replace
- FormatTime use genericity
- add Close,close io.Closer
- init version
MIT