ZhangZhihui's Blog  
上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 78 下一页

2024年6月13日

摘要: package main import ( "context" "fmt" "os" "strconv" "time" "golang.org/x/sync/semaphore" ) func worker(n int) int { square := n * n time.Sleep(time.S 阅读全文
posted @ 2024-06-13 20:26 ZhangZhihuiAAA 阅读(15) 评论(0) 推荐(0) 编辑
 
摘要: Reading from a closed channel returns the zero value of its data type. However, if you try to write to a closed channel, your program is going to cras 阅读全文
posted @ 2024-06-13 19:36 ZhangZhihuiAAA 阅读(5) 评论(0) 推荐(0) 编辑

2024年6月12日

摘要: pflag is a drop-in replacement of Go's native flag package. If you import pflag under the name "flag" then all code should continue to function with n 阅读全文
posted @ 2024-06-12 16:55 ZhangZhihuiAAA 阅读(3) 评论(0) 推荐(0) 编辑
 
摘要: package main import ( "bufio" "fmt" "io" "os" ) func main() { buffer := []byte("Data to write\n") f1, err := os.Create("f1.txt") if err != nil { fmt.P 阅读全文
posted @ 2024-06-12 14:37 ZhangZhihuiAAA 阅读(5) 评论(0) 推荐(0) 编辑
 
摘要: The purpose of the /dev/random system device is to generate random data, which you might use to test your programs or, in this case, as the seed for a 阅读全文
posted @ 2024-06-12 14:13 ZhangZhihuiAAA 阅读(5) 评论(0) 推荐(0) 编辑
 
摘要: package main import ( "bufio" "fmt" "io" "os" ) func lineByLine(file string) error { f, err := os.Open(file) if err != nil { return err } defer f.Clos 阅读全文
posted @ 2024-06-12 10:53 ZhangZhihuiAAA 阅读(6) 评论(0) 推荐(0) 编辑

2024年6月11日

摘要: package main import ( "database/sql" "fmt" "os" _ "github.com/mattn/go-sqlite3" ) func main() { // Connect or create a SQLite database db, err := sql. 阅读全文
posted @ 2024-06-11 20:02 ZhangZhihuiAAA 阅读(4) 评论(0) 推荐(0) 编辑
 
摘要: If there are multiple init() functions in a package, don't use in an init() function a global variable that is initialized in another init() function, 阅读全文
posted @ 2024-06-11 19:47 ZhangZhihuiAAA 阅读(4) 评论(0) 推荐(0) 编辑
 
摘要: Remember that the biggest advantage you get from using a map[string]interface{} map, or any map that stores an interface{} value in general, is that y 阅读全文
posted @ 2024-06-11 19:27 ZhangZhihuiAAA 阅读(5) 评论(0) 推荐(0) 编辑
 
摘要: package main import ( "fmt" "reflect" ) type Secret struct { Username string Password string } type Record struct { Field1 string Field2 float64 Field 阅读全文
posted @ 2024-06-11 17:07 ZhangZhihuiAAA 阅读(4) 评论(0) 推荐(0) 编辑
上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 78 下一页