Created
          November 11, 2011 01:07 
        
      - 
      
- 
        Save jswank/1356812 to your computer and use it in GitHub Desktop. 
    Struct w/ nil-map; Printf w/ bool values
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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"] ) | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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]) | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
just a test comment.