Created
January 26, 2015 20:43
-
-
Save Igosuki/74e27bf36fef60c88a34 to your computer and use it in GitHub Desktop.
Go Examples
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" | |
"os" | |
) | |
const n = 500000000 | |
func main() { | |
fmt.Println("hello world", "motherfucker") | |
fmt.Println("1-3", "=", 1-3) | |
i, err := fmt.Printf("%T", 3) | |
var f int | |
f, t := 1, "eee" | |
fmt.Fprintln(os.Stdout, f, t, i, err) | |
const d = 3e20 / n | |
fmt.Println(d) | |
var a [5]int | |
fmt.Println(a) | |
s := make([]int, 4, 10) | |
s[0] = 2 | |
s[1] = 2 | |
s[2] = 2 | |
s[3] = 2 | |
s2 := append(s, 6) | |
fmt.Println(s) | |
s2[1] = 4 | |
fmt.Println(s2) | |
fmt.Println(s) | |
m := make(map[string]int) | |
m["babab"] = 0 | |
m["bab"] = 10 | |
m["babsdab👆👆👆"] = 120 | |
fmt.Println("...", m) | |
for k, v := range m { | |
println(k, v) | |
} | |
swo := new(Main) | |
r, err := swo.do(0, 1) | |
println(r, err) | |
swo.B.doAV() | |
} | |
type Main struct { | |
*A | |
B | |
} | |
type B struct { | |
} | |
func (b B) doAV() { | |
fmt.Println("do BV") | |
} | |
type A struct { | |
} | |
func (a *A) doA() { | |
fmt.Println("do *A") | |
} | |
func (a A) doAV() { | |
fmt.Println("do AV") | |
} | |
func (m Main) do(a int, b int) (int, error) { | |
return a + b, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment