本文整理汇总了Golang中golang.org/x/tour/pic.Show函数的典型用法代码示例。如果您正苦于以下问题:Golang Show函数的具体用法?Golang Show怎么用?Golang Show使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Show函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
fmt.Println("### Start Slice Exercise ###")
pic.Show(Pic)
fmt.Println("### End Slice Exercise ###")
}
示例2: main
func main() {
pointer()
v := Vertex{1, 2}
v.X = 4
fmt.Println(v)
p := &v
p.X = 1e9
fmt.Println(v)
structLiterals()
array()
slice()
tictactoe()
slicing()
makeslice()
zeroSlice()
appendSlice()
ranges()
pic.Show(Pic)
var vLL = VertexLL{40.68433, -74.39967}
geography("Bell Labs", vLL)
fmt.Println(m["Bell Labs"])
vLL = VertexLL{37.4828, 122.2361}
geography("Redwood City", vLL)
fmt.Println(m["Redwood City"])
fmt.Println(m)
mutateMap()
wc.Test(WordCount)
fmt.Println(hypot(5, 12))
fmt.Println(compute(hypot))
fmt.Println(compute(math.Pow))
exAdder()
f := fibonacci()
for i := 0; i < 10; i++ {
fmt.Println(f())
}
}
示例4: TestExerciseSlices
func TestExerciseSlices(t *testing.T) {
pic.Show(Pic)
}
示例5: main
func main() {
i, j := 42, 2701
// pointer to i
p := &i
fmt.Println(p, " -> ", *p)
p = &j
fmt.Println(p, " -> ", *p)
*p = i
fmt.Println(p, " -> ", *p)
v1 := Vertex{4, 5}
v2 := Vertex{X: 9, Y: 9}
v3 := Vertex{X: 9} // Y=0 is implicit
fmt.Println(v1.X)
fmt.Println(v2, v3)
// arrays
var s1 [2]string
s1[0] = "hi"
s1[1] = "there"
fmt.Println("a[0]: ", s1[0])
fmt.Println("a: ", s1)
arr := []int{1, 2, 4, 5, 23, 123, 5, 0}
fmt.Println("arr ==", arr)
for i := 0; i < len(arr); i++ {
fmt.Printf("arr[%d] == %d\n", i, arr[i])
}
fmt.Println("arr[:3] == ", arr[:3])
fmt.Println("arr[2:5] == ", arr[2:5])
fmt.Println("arr[5:] == ", arr[5:])
fmt.Println("arr[:] == ", arr[:])
a := make([]int, 5)
printSlice("a", a)
b := make([]int, 0, 5)
printSlice("b", b)
c := b[:2]
printSlice("c", c)
d := c[2:5]
printSlice("d", d)
var z []int
// zero value for empty array is nil
if z == nil {
fmt.Println("nil,", z)
}
printSlice("z", z)
z = append(z, 1)
z = append(z, 2)
z = append(z, 4)
var z2 []int = append(z, 3, 5, 6)
printSlice("z", z)
printSlice("z", z2)
for i, v := range pow {
fmt.Printf("2^%d = %d\n", i, v)
}
pwrs := make([]int, 10)
for i := range pwrs {
pwrs[i] = 1 << uint(i)
}
for _, val := range pwrs {
fmt.Println(val)
}
pic.Show(Pic)
var m map[string]Vertex
m = make(map[string]Vertex)
m["Bell labs"] = Vertex{342, 4532}
var m2 = map[string]Vertex{
"Google": {33, 44},
"General Electric": {54322, 3423},
"deleteme": {},
}
delete(m2, "deleteme")
fmt.Println(m, m2)
// functions
hypnot := func(x, y float64) float64 {
return math.Sqrt(x*x + y*y)
}
//.........这里部分代码省略.........
示例6: main
////Learning material used from
//https://tour.golang.org/moretypes/15
//GoTour needs to be installed locally
func main() {
rand.Seed(time.Now().UTC().UnixNano())
pic.Show(Pic)
}
示例7: main
func main() {
pic.Show(Pic)
fmt.Println("hello, world")
}
示例9: main
//.........这里部分代码省略.........
fmt.Println(zNil, len(zNil), cap(zNil))
if zNil == nil {
fmt.Println("nil!")
}
var a2 []int
printSlice("a2", a2)
// append works on nil slices.
a2 = append(a2, 0)
printSlice("a2", a2)
// the slice grows as needed.
a2 = append(a2, 1)
printSlice("a2", a2)
// we can add more than one element at a time.
a2 = append(a2, 2, 3, 4)
printSlice("a2", a2)
// range
for i, v := range pow2 {
fmt.Printf("2**%d = %d\n", i, v)
}
pow3 := make([]int, 10)
for i := range pow3 {
pow3[i] = 1 << uint(i)
}
for _, value := range pow3 {
fmt.Printf("%d\n", value)
}
pic.Show(Pic)
// Maps
map1 = make(map[string]LocationCoordinate)
map1["Bell Labs"] = LocationCoordinate{
40.68433, -74.39967,
}
fmt.Println(map1["Bell Labs"])
fmt.Println(map1)
fmt.Println(map2)
//Mutating Maps
map3 := make(map[string]int)
map3["Answer"] = 42
fmt.Println("The value:", map3["Answer"])
v6, ok1 := map3["Answer"]
fmt.Println("The value:", v6, "Present?", ok1)
map3["Answer"] = 48
fmt.Println("The value:", map3["Answer"])
delete(map3, "Answer")
fmt.Println("The value:", map3["Answer"])
v6, ok2 := map3["Answer"]
fmt.Println("The value:", v6, "Present?", ok2)
// map exercise
wc.Test(WordCount)
示例11: main
func main() {
pic.Show(Pic)
pic.Show(PicRange)
}
示例12: testPic
func testPic() {
pic.Show(Pic)
}
示例13: main
// 参考 https://tour.go-zh.org/moretypes/15
func main() {
// nice choice (x+y)/2、x*y 和 x^y
pic.Show(Pic)
}