Skip to content

Instantly share code, notes, and snippets.

@jswank
Created November 11, 2011 01:07
Show Gist options
  • Save jswank/1356812 to your computer and use it in GitHub Desktop.
Save jswank/1356812 to your computer and use it in GitHub Desktop.
Struct w/ nil-map; Printf w/ bool values
package main
import "fmt"
type Foo struct {
exists map[string] bool
}
func newFoo() (*Foo) {
exists := make(map[string] bool)
s := &Foo{exists: exists}
return s
}
func main() {
foo := newFoo()
foo.exists["bar"] = true
fmt.Printf("\"huh\" in map? %t\n", foo.exists["huh"] )
fmt.Printf("\"bar\" in map? %t\n", foo.exists["bar"] )
}
package main
import "fmt"
import "strings"
func main() {
path_info := strings.Split("/foo/bar", "/")
fmt.Printf("first component: %s, second component: %s", path_info[1], path_info[2])
}
@jswank
Copy link
Author

jswank commented Nov 11, 2011

just a test comment.

@jswank
Copy link
Author

jswank commented Dec 7, 2011

Another comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment