摘要:
```go package main import ( "fmt" "log" "os/user"
) func main() { usr, err := user.Current() if err != nil { log.Fatal(err) } fmt.Println("The user home directory: " + usr.HomeDir)
} /*... 阅读全文
posted @ 2018-03-23 23:44
cucy_to
阅读(145)
评论(0)
推荐(0)
摘要:
```go package main import ( "bufio" "crypto/md5" "fmt" "io" "os"
) var data = []struct { name string cont string perm os.FileMode
}{ {"test1.file", "Hello\nGolang is great", 0666}, {"test... 阅读全文
posted @ 2018-03-23 23:42
cucy_to
阅读(150)
评论(0)
推荐(0)
摘要:
```go package main import ( "fmt" "os" "path/filepath" ) func main() { for i := 1; i 阅读全文
posted @ 2018-03-23 23:40
cucy_to
阅读(99)
评论(0)
推荐(0)
摘要:
```go package main import ( "os"
) func main() { f, err := os.Create("created.file") if err != nil { panic(err) } f.Close() f, err = os.OpenFile("created.byopen", os.O_CREATE|os.O_APPEND,... 阅读全文
posted @ 2018-03-23 23:38
cucy_to
阅读(82)
评论(0)
推荐(0)
摘要:
```go package main import ( "fmt" "os"
) func main() { f, err := os.Create("test.file") if err != nil { panic(err) } defer f.Close() // Obtain current permissions fi, err := f.Stat() ... 阅读全文
posted @ 2018-03-23 23:36
cucy_to
阅读(126)
评论(0)
推荐(0)
摘要:
```go package main import ( "fmt" "io/ioutil" "os" "path/filepath"
) func main() { fmt.Println("List by ReadDir") listDirByReadDir(".") fmt.Println() fmt.Println("List by Walk") listDirBy... 阅读全文
posted @ 2018-03-23 23:34
cucy_to
阅读(470)
评论(0)
推荐(1)
摘要:
```go package main import ( "fmt" "io" "os" "sync"
) type SyncWriter struct { m sync.Mutex Writer io.Writer
} func (w *SyncWriter) Write(b []byte) (n int, err error) { w.m.Lock() defe... 阅读全文
posted @ 2018-03-23 23:31
cucy_to
阅读(280)
评论(0)
推荐(0)
摘要:
```go package main import ( "io" "os" "strings"
) func main() { f, err := os.Create("sample.file") if err != nil { panic(err) } defer f.Close() _, err = f.WriteString("Go is awesome!\n... 阅读全文
posted @ 2018-03-23 23:28
cucy_to
阅读(79)
评论(0)
推荐(0)
摘要:
```go package main import "io/ioutil"
import "os"
import "fmt" func main() { tFile, err := ioutil.TempFile("", "gostdcookbook") if err != nil { panic(err) } // The called is responsible for h... 阅读全文
posted @ 2018-03-23 23:26
cucy_to
阅读(235)
评论(0)
推荐(0)
摘要:
```go package main import ( "fmt" "os"
) func main() { f, err := os.Open("test.file") if err != nil { panic(err) } fi, err := f.Stat() if err != nil { panic(err) } fmt.Printf("File n... 阅读全文
posted @ 2018-03-23 23:24
cucy_to
阅读(103)
评论(0)
推荐(0)

浙公网安备 33010602011771号