摘要:
```go package main import ( "encoding/json" "fmt" "strings" ) const js = ` [{ "name":"Axel", "lastname":"Fooley" }, { "name":"Tim", "lastname":"Burton 阅读全文
posted @ 2018-03-22 01:13
cucy_to
阅读(116)
评论(0)
推荐(0)
摘要:
```go package main import ( "archive/zip" "bytes" "fmt" "io" "io/ioutil" "log" "os"
) func main() { var buff bytes.Buffer // Compress content zipW := zip.NewWriter(&buff) f, err := zip... 阅读全文
posted @ 2018-03-22 01:08
cucy_to
阅读(136)
评论(0)
推荐(0)
摘要:
```go package main import ( "bytes" "encoding/gob" "fmt" ) type User struct { FirstName string LastName string Age int Active bool } func (u User) Str 阅读全文
posted @ 2018-03-22 01:07
cucy_to
阅读(136)
评论(0)
推荐(0)
摘要:
```go package main import ( "io" "log" "os" "os/exec"
) func main() { pReader, pWriter := io.Pipe() cmd := exec.Command("echo", "Hello Go!\nThis is example") cmd.Stdout = pWriter go func(... 阅读全文
posted @ 2018-03-22 01:05
cucy_to
阅读(166)
评论(0)
推荐(0)
摘要:
```go
package main import "io"
import "bytes"
import "os"
import "fmt" func main() { buf := bytes.NewBuffer([]byte{}) f, err := os.OpenFile("sample.txt", os.O_CREATE|os.O_RDWR, os.ModePerm) if e... 阅读全文
posted @ 2018-03-22 01:02
cucy_to
阅读(382)
评论(0)
推荐(1)
摘要:
```go package main import ( "bytes" "encoding/binary" "fmt"
) func main() { // Writing binary values buf := bytes.NewBuffer([]byte{}) if err := binary.Write(buf, binary.BigEndian, 1.004); er... 阅读全文
posted @ 2018-03-22 00:59
cucy_to
阅读(129)
评论(0)
推荐(0)
摘要:
```go package main import ( "errors" "fmt" "os" ) const lineLegth = 25 func main() { f, e := os.OpenFile("flatfile.txt", os.O_RDWR|os.O_CREATE, os.ModePerm) if e != nil { panic(e) } defe... 阅读全文
posted @ 2018-03-22 00:57
cucy_to
阅读(157)
评论(0)
推荐(0)
摘要:
```go package main import ( "fmt" "io/ioutil" "os" "golang.org/x/text/encoding/charmap"
) func main() { // Write the string // encoded to Windows-1252 encoder := charmap.Windows1252.NewEnc... 阅读全文
posted @ 2018-03-22 00:54
cucy_to
阅读(111)
评论(0)
推荐(0)
摘要:
```go package main import "os"
import "bufio" import "bytes"
import "fmt"
import "io/ioutil" func main() { fmt.Println("### Read as reader ###") f, err := os.Open("temp/file.txt") if err != ni... 阅读全文
posted @ 2018-03-22 00:51
cucy_to
阅读(123)
评论(0)
推荐(0)
摘要:
```go package main import ( "fmt" "io" "io/ioutil" "os"
) func main() { f, err := os.Open("temp/file.txt") if err != nil { panic(err) } c, err := ioutil.ReadAll(f) if err != nil { pa... 阅读全文
posted @ 2018-03-22 00:48
cucy_to
阅读(299)
评论(0)
推荐(0)

浙公网安备 33010602011771号