Created
October 19, 2012 13:48
-
-
Save pote/3918320 to your computer and use it in GitHub Desktop.
This file contains 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 uuid "github.com/nu7hatch/gouuid" | |
import ( | |
"fmt" | |
uuid "github.com/nu7hatch/gouuid" | |
) | |
func main() { | |
// *snip* | |
} |
This file contains 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
if vince.IsOutOfTheToilet() { | |
// kill the bastard! | |
} else { | |
// stay cool... | |
} | |
// WROOOONG! | |
if mia.IsOverdosed() | |
vince.ApplyAdrenalineTo(mia) | |
if vince, ok := people["Vince"]; !ok { | |
panic "Jules is dead!" | |
} |
This file contains 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
const foo = 1 | |
const ( | |
one = iota | |
two | |
three | |
four | |
) |
This file contains 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
func IDoNothingWrong() { | |
} | |
func PrintMotherfucker(something string) { | |
fmt.Println(something + " motherfucker!") | |
} | |
func PrintMoreMotherfuckers(one, two string, three int) { | |
fmt.Printf("%s, %s, %d motherfucker!\n", one, two, three) | |
} | |
func PrintAllTheThings(args ...string) { | |
fmt.Println(args...) | |
} | |
This file contains 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
func IsJulesAlive() bool { | |
return true | |
} | |
func SayToVince(phrase string) (bool, error) { | |
return nil, errors.New("Vince is dead!") | |
} | |
func SayToVince(phrase string) (ok boo, err error) { | |
err = errors.New("Vince is dead!") | |
return | |
} |
This file contains 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
for i := 0; i < 100; i++ { | |
fmt.Println(i) | |
} | |
i := 0; | |
for i < 1000 { | |
fmt.Println(i) | |
i++ | |
} | |
for name, motherfucker := range motherfuckers { | |
motherfucker.Kill() | |
fmt.Printf("%s is fucking dead\n", name") | |
} |
This file contains 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
var people map[string]Person | |
people = make(map[string]Person) | |
people := make(map[string]Person) | |
people := map[string]Person{} | |
jules := people["Jules"] | |
delete(people, "Vince") |
This file contains 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
var people []Person | |
people := make([]Person, 5) | |
dumbNumbers := []int{1,2,3,4} | |
len(dumbNumbers) // => 4 | |
cap(people) // => 5 | |
motherfuckers := people[1:3] | |
dumbNumbers := append(dumbNumbers, 5) |
This file contains 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
type Vince struct { | |
Stoned bool | |
} | |
type Stoner struct { | |
Stoned bool | |
} | |
type Vince struct { | |
Stoner | |
} | |
var vince Vince | |
var vince = Vince{true} | |
var vince = &Vince{true} | |
func NewVince() *Vince { | |
return &Vince{stoned: true} | |
} |
This file contains 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
var ( | |
name string | |
age int = 32 | |
) | |
func IDoNothingWrong() { | |
var name string | |
age := 32 | |
// *snip* | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment