Go语言中文网 为您找到相关结果 5

golang: if block ends with a return statement, so drop this else and outdent its block

golang中有一条代码规范检查: if block ends with a return statement, so drop this else and outdent its block 例如以下代码: else处会提示: if block ends with a return statement, so drop this else and outdent its blockgo-lint if k8serrors.IsNotFound(err) { c.deletePodQueue.Add(key) return } else { klog.Errorf("failed to get statefulset %v", err) return } 网上搜索有部分不太正确的解释或者修改...阅读全文

博文 2019-12-25 01:32:55 老廖2018

golang检测ip,port

package main import ( "fmt" "net" "os/exec" "strconv" "strings" ) func main() { err := CheckPorts("3306") if err != nil { fmt.Println("端口已存在") } else { fmt.Println("端口不存在") } // GetLocalIps() } //获取本机ip func GetLocalIp() string { addrs, err := net.InterfaceAddrs() if err != nil { fmt.Println("get local ip failed") } for _, address := range addrs { ...阅读全文

博文 2020-04-07 15:32:49 成功的失败者

golang的一些点

select case的用法 context库的用法 随机数发生器的用法 rand.NewSource() rand.Seed(time.Now().Nanosecond()) rand.IntN(100) sync.Once的用法 Happens-before原则、Observe原则 CAS 双重检测 atomic库的用法 golang调试工具delve的一些知识 Installation on macOS Ensure you have a proper compilation toolchain. This should be as simple as: xcode-select --install Now you can install delve using go ge...阅读全文

博文 2020-02-03 19:32:43 王艳秋1