上一页 1 ··· 106 107 108 109 110 111 112 113 114 ··· 492 下一页
摘要: var name string var namePointer *string // Pointer name = "Beyonce" namePointer = &name // Assign a Pointer fmt.Println("Name: ", name) fmt.Println("N 阅读全文
posted @ 2022-09-06 01:42 Zhentiw 阅读(24) 评论(0) 推荐(0)
摘要: package main import "fmt" type User struct { ID int FirstName string LastName string Email string } func main() { u := User{ID: 1, FirstName: "Z", Las 阅读全文
posted @ 2022-09-05 15:13 Zhentiw 阅读(16) 评论(0) 推荐(0)
摘要: file: utils/math.go package utils import ( "fmt" ) func printNum(num int) { fmt.Println("Current number is: ", num) } // Add multi int number together 阅读全文
posted @ 2022-09-05 14:57 Zhentiw 阅读(15) 评论(0) 推荐(0)
摘要: Create a new folder utilswith a new file math.go package utils import ( "fmt" ) func printNum(num int) { fmt.Println("Current number is: ", num) } // 阅读全文
posted @ 2022-09-05 14:49 Zhentiw 阅读(25) 评论(0) 推荐(0)
摘要: A Go map type looks like this: map[KeyType]ValueType This variable m is a map of string keys to int values: var m map[string]int Map types are referen 阅读全文
posted @ 2022-09-05 14:28 Zhentiw 阅读(21) 评论(0) 推荐(0)
摘要: An array has a fixed size. A slice, on the other hand, is a dynamically-sized, flexible view into the elements of an array. In practice, slices are mu 阅读全文
posted @ 2022-09-05 14:11 Zhentiw 阅读(26) 评论(0) 推荐(0)
摘要: Slices can be created with the built-in make function; this is how you create dynamically sized arrays. The make function allocates a zeroed array and 阅读全文
posted @ 2022-09-04 22:50 Zhentiw 阅读(24) 评论(0) 推荐(0)
摘要: package main import ( "fmt" ) func main() { //var scores [5]float64 //fmt.Println(scores) // [0.0, 0.0,0.0,0.0,0.0] //var scores [5]float64 = [5]float 阅读全文
posted @ 2022-09-04 20:13 Zhentiw 阅读(17) 评论(0) 推荐(0)
摘要: Function can return multi values: func printAge(age int) (int, int) { return 12, age } func main() { age1, age2 := printAge(8) fmt.Println(age1) fmt.P 阅读全文
posted @ 2022-09-04 20:07 Zhentiw 阅读(20) 评论(0) 推荐(0)
摘要: There is no While loop in Go, but you can use For loop as while loop: i := 1 for i < 100 { fmt.Println(i) i += 1 } func main() { var myTxt = "This is 阅读全文
posted @ 2022-09-04 16:29 Zhentiw 阅读(19) 评论(0) 推荐(0)
上一页 1 ··· 106 107 108 109 110 111 112 113 114 ··· 492 下一页