golang
已收录文章:13782篇
-
首先撰写golang程序exportgo.go: package main import "C" import "fmt" //export PrintBye func PrintBye() { fmt.Println("From DLL: Bye!") } //export Sum func Sum(a int, b int) int { return a + b; } func main() { // Need a main func489 收藏
-
在go的微服务架构中 使用go-kit组件进行开发微服务 type Reg struct { Host string Port int Client consul.Client } func MakeReg (host string , port int) (*Reg , error) { reg := api.DefaultConfig() reg.Address = host + ":" + strconv.It489 收藏
-
最近用go写程序时遇到一个问题——求任意类型切片的长度。 作为一个初学者,刚刚学了接口和切片,知道了每个类型都实现了一个空接口interface{},那么如果接口类型作为函数的参数,那它应489 收藏
-
源码中的 nil 是这样定义的 // nil is a predeclared identifier representing the zero value for a // pointer, channel, func, interface, map, or slice type. var nil Type // Type must be a pointer, channel, func, interface, map, or slice type 所489 收藏
-
问题内容 我用的github.com/go-sql-driver/mysql这个驱动,我像下面这样写没有报错,但是里面的数据为空或者0 type data struct { id int name string weight int } rows, _ := db.Query("select * from test where id = ?",489 收藏
-
问题内容 func test_gomaxprocs() { runtime.GOMAXPROCS(1) wg := sync.WaitGroup{} wg.Add(20) for i := 0; i < 10; i++ { go func() { fmt.Println("i:", i) defer wg.Done() }() } for i := 0;489 收藏