上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 44 下一页
摘要: 点击查看代码 package main import "fmt" func test(a interface{}){ fmt.Printf("你好啊%#v==%v==%T==%p\n",a,a,a,&a) // 将接口类型的变量转化为具体类型 加个OK 判断, 可以避免程序直接崩溃, ok=fals 阅读全文
posted @ 2022-03-07 23:22 ty1539 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 package main import "fmt" type Animal interface{ Talk() Eat() Name() string } type Dog struct{} func (d Dog) Talk(){ fmt.Println("汪汪汪") } func 阅读全文
posted @ 2022-03-07 23:09 ty1539 阅读(17) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 package main import "fmt" type Animal interface{ Talk() Eat() Name() string //string 是方法返回的类型 } type Describle interface{ Describle() } type Av 阅读全文
posted @ 2022-03-07 22:08 ty1539 阅读(23) 评论(0) 推荐(0) 编辑
摘要: https://github.com/markusleevip/go-shici https://github.com/joizhang/learn-golang 阅读全文
posted @ 2022-03-07 21:41 ty1539 阅读(32) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 package main import ( "encoding/json" "fmt" "reflect" // 这里引入reflect模块 ) func testTag1(){ type A struct { B string `tag1:"b" tag2:"B" tag3:"d"` 阅读全文
posted @ 2022-03-06 23:54 ty1539 阅读(67) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" ) type User struct{ Username string Sex string Age int AvatarUrl string } func initUser1() { var user *User fmt.Printf("us 阅读全文
posted @ 2022-03-06 23:36 ty1539 阅读(152) 评论(0) 推荐(0) 编辑
摘要: json 序列化 package main import ( "encoding/json" "fmt" ) type User struct { UserName string `json:"姓名"` // 有了tag,序列化出来的就是tag中的名字 Sex string `json:"性别"` 阅读全文
posted @ 2022-03-06 23:27 ty1539 阅读(260) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 package main import( "fmt" ) func testIf(){ var num int =2 if num == 1{ fmt.Printf("num:%d num==1 \n",num) }else if num == 2{ fmt.Printf("num:% 阅读全文
posted @ 2022-03-06 23:17 ty1539 阅读(20) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 package main import ( "fmt" ) func testFor1() { var i int for i = 1; i <= 10; i++ { fmt.Printf("i=%d\n", i) } fmt.Printf("最终的i=%d\n", i) } func 阅读全文
posted @ 2022-03-06 23:12 ty1539 阅读(23) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 package main import "fmt" // 选择排序 func insert_sort(a [8]int) [8]int { for i := 1; i<len(a); i++{ for j := i; j>0; j--{ if a[j] < a[j-1] { a[j], 阅读全文
posted @ 2022-03-06 22:57 ty1539 阅读(18) 评论(0) 推荐(0) 编辑
上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 44 下一页