Skip to content

Instantly share code, notes, and snippets.

@mvrilo
Created December 18, 2013 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvrilo/8019479 to your computer and use it in GitHub Desktop.
Save mvrilo/8019479 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
p "github.com/kr/pretty"
)
func main() {
type myType struct {
c []byte
a, b int
d map[string]string
}
var x = []myType{{[]byte("ha"), 1, 2, map[string]string{"key": "val"}}, {[]byte("a"), 3, 4, map[string]string{"meh": "t"}}}
p.Println(x)
fmt.Printf("%# v\n-------\n", x)
var z = new(myType)
z.a = 1
z.b = 3
z.c = []byte("testing")
z.d = map[string]string{"he": "ha"}
p.Println(z)
fmt.Printf("%# v\n-------\n", z)
p.Println(fmt.Sprintf)
fmt.Printf("%# v\n-------\n", fmt.Sprintf)
/* output:
[]main.myType{
{
c: {0x68, 0x61},
a: 1,
b: 2,
d: {"key":"val"},
},
{
c: {0x61},
a: 3,
b: 4,
d: {"meh":"t"},
},
}
[]main.myType{main.myType{c:[]uint8{ 0x68, 0x61}, a: 1, b: 2, d:map[string]string{"key":"val"}}, main.myType{c:[]uint8{ 0x61}, a: 3, b: 4, d:map[string]string{"meh":"t"}}}
-------
&main.myType{
c: {0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67},
a: 1,
b: 3,
d: {"he":"ha"},
}
&main.myType{c:[]uint8{ 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67}, a: 1, b: 3, d:map[string]string{"he":"ha"}}
-------
func(string, ...interface {}) string {...}
(func(string, ...interface {}) string)( 0x27130)
-------
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment