144
10 things you (probably) don't know about Go
source link: https://talks.golang.org/2012/10things.slide
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
10 things you (probably) don't know about Go
10 things you (probably) don't know about Go
Andrew Gerrand
Gopher
1. Anonymous structs
- Grouped globals
var config struct { APIKey string OAuthConfig oauth.Config } config.APIKey = "BADC0C0A"
- Template data
data := struct { Title string Users []*User }{ title, users, } err := tmpl.Execute(w, data)
(Cheaper and safer than using map[string]interface{}
.)
2
1b. Anonymous structs
- Test tables
var indexRuneTests = []struct { s string rune rune out int }{ {"a A x", 'A', 2}, {"some_text=some_value", '=', 9}, {"☺a", 'a', 3}, {"a☻☺b", '☺', 4}, }
- Embedded lock
var hits struct { sync.Mutex n int } hits.Lock() hits.n++ hits.Unlock()
3
Use the left and right arrow keys or click the left and right
edges of the page to navigate between slides.
(Press 'H' or navigate to hide this message.)
(Press 'H' or navigate to hide this message.)
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK