golang常见错误
发布时间:2020-12-16 09:34:13 所属栏目:大数据 来源:网络整理
导读:import import unuse package:error : imported and not used: "os" := = c := 1 // error non-declaration statement outside function bodyd = 1 // error non-declaration statement outside function body func test(){ c = 1 //undefined: should be c:
importimport unuse package: error : imported and not used: "os" := =c := 1 // error non-declaration statement outside function body d = 1 // error non-declaration statement outside function body func test(){ right using value declare and usepackage main import "fmt" //var a := 0 //wrong var a int = 0 //c := 1 //wrong //d = 1 //wrong func cal(b int)(val1 int,val2 int){ fmt.Println(b) val1 = 1 val2 = 2 return } func test(){ c := 1 //d = 1 //wrong var f,d int f,d = cal(1) fmt.Println(c,d) } func main() { fmt.Println("Hello,world var") } declear not use./right.go:14: c declared and not used type struct init using (),instead of {},which {} is the right usagetype Response struct { Code string `json:"code"` Body string `json:"body"` } //not like this () //Response("OK","ECHO: " + method + " ~ " + params) //right usage {} Response{"OK","ECHO: " + method + " ~ " + params} 如何理解以下代码:type IpcClient struct { conn chan string } func (client *IpcClient)Call(method,params string)(resp *Response,err error){ }
wrong not using go keyworld when call async func(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |