摘要:
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
阅读(9)
推荐(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
阅读(11)
推荐(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
阅读(17)
推荐(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
阅读(10)
推荐(0)
摘要:
package main import ( "fmt" "maps" ) func delete(k string, v int) bool { return v%2 != 0 } func equal(v1 int, v2 float64) bool { return float64(v1) ==
阅读全文
posted @ 2024-06-11 11:35
ZhangZhihuiAAA
阅读(15)
推荐(0)
摘要:
package main import ( "fmt" "slices" ) func main() { s1 := []int{1, 2, -1, -2} s2 := slices.Clone(s1) fmt.Printf("%p\n", s1) fmt.Printf("%p\n", s2) s1
阅读全文
posted @ 2024-06-11 11:22
ZhangZhihuiAAA
阅读(11)
推荐(0)
posted @ 2024-06-11 10:12
ZhangZhihuiAAA
阅读(14)
推荐(0)
摘要:
package main import ( "encoding/csv" "log" "os" ) type Record struct { Name string Surname string Number string LastAccess string } var myData = []Rec
阅读全文
posted @ 2024-06-10 20:58
ZhangZhihuiAAA
阅读(11)
推荐(0)
posted @ 2024-06-10 20:16
ZhangZhihuiAAA
阅读(6)
推荐(0)
摘要:
package main import ( crand "crypto/rand" "encoding/base64" "fmt" mrand "math/rand" "strings" ) const ( // As we only want to get printable ASCII char
阅读全文
posted @ 2024-06-10 17:40
ZhangZhihuiAAA
阅读(19)
推荐(0)