github.com/neugram/ng@v0.0.0-20180309130942-d472ff93d872/eval/testdata/import2.ng (about) 1 ok := true 2 3 import "bytes" 4 import "io" 5 buf := new(bytes.Buffer) 6 buf.WriteString("OK") 7 type reader interface { 8 Read(p []uint8) (n int, err error) 9 } 10 r := reader(buf) 11 b := make([]uint8, 2) 12 io.ReadFull(r, b) 13 res := string(string(b)) 14 if res != "OK" { 15 printf("res=%q, want %q", res, "OK") 16 ok = false 17 } 18 19 import "encoding/base64" 20 x := base64.StdEncoding.EncodeToString([]byte("hello")) 21 y := base64.StdEncoding.DecodeString(x) 22 if got, want := string(y), "hello"; got != want { 23 printf("got=%q, want %q", got, want) 24 ok = false 25 } 26 27 if ok { 28 print("OK") 29 }