goang ioutil.ReadFile使用相对路径
func FileCopy(src, dst string) bool {
pwd, _ := os.Getwd()
osPart := "/"
if runtime.GOOS == "windows" {
osPart = "\\"
}
src = pwd + osPart + src
byteSlice, err := ioutil.ReadFile(src)
if err != nil {
log.Println(err)
return false
}
WriteWithIoutilByte(dst, byteSlice)
return true
}
func WriteWithIoutilByte(name string, content []byte) {
if ioutil.WriteFile(name, content, 0644) == nil {
log.Println("写入文件成功", name)
}
}