go

Variable declared and not used in conditional statement

Deadly 提交于 2021-02-07 08:43:52
问题 I declare some variables ( offsetI and limitI ) outside of a conditional statement. Inside the conditional statement I am trying to assign them values, then use those values for a query after the conditional statement. var ( number, size, offset, limit string offsetI, limitI uint64 ) // Get the string values for number, size, offset, and limit // ... if size != "" { // Parse the number value numberI, err := strconv.ParseUint(number, 10, 64) if err != nil {...} // Parse the size value limitI,

Sending directly from one channel to another

吃可爱长大的小学妹 提交于 2021-02-07 08:43:28
问题 I stumbled upon what I found to be surprising behavior when sending from one channel directly to another channel: package main import ( "fmt" ) func main() { my_chan := make(chan string) chan_of_chans := make(chan chan string) go func() { my_chan <- "Hello" }() go func() { chan_of_chans <- my_chan }() fmt.Println(<- <- chan_of_chans) } Go Playground I expected <- my_chan to send "Hello" type string . However, it sends type chan string and my code runs fine. This means that what is being (

unmarshal generic json in Go

好久不见. 提交于 2021-02-07 08:42:11
问题 I'm a new Go programmer (From Java) and I would like to reproduce a generic way which is esay to use in Java. I want to create some function which allow me to do an Unmarshal on a JSON string in order to avoid code duplicity. This is my current code which is not working : type myStruct1 struct { id string name string } func (obj myStruct1) toString() string { var result bytes.Buffer result.WriteString("id : ") result.WriteString(obj.id) result.WriteString("\n") result.WriteString("name : ")

Sending directly from one channel to another

自作多情 提交于 2021-02-07 08:42:07
问题 I stumbled upon what I found to be surprising behavior when sending from one channel directly to another channel: package main import ( "fmt" ) func main() { my_chan := make(chan string) chan_of_chans := make(chan chan string) go func() { my_chan <- "Hello" }() go func() { chan_of_chans <- my_chan }() fmt.Println(<- <- chan_of_chans) } Go Playground I expected <- my_chan to send "Hello" type string . However, it sends type chan string and my code runs fine. This means that what is being (

Variable declared and not used in conditional statement

安稳与你 提交于 2021-02-07 08:41:24
问题 I declare some variables ( offsetI and limitI ) outside of a conditional statement. Inside the conditional statement I am trying to assign them values, then use those values for a query after the conditional statement. var ( number, size, offset, limit string offsetI, limitI uint64 ) // Get the string values for number, size, offset, and limit // ... if size != "" { // Parse the number value numberI, err := strconv.ParseUint(number, 10, 64) if err != nil {...} // Parse the size value limitI,

Variable declared and not used in conditional statement

对着背影说爱祢 提交于 2021-02-07 08:39:30
问题 I declare some variables ( offsetI and limitI ) outside of a conditional statement. Inside the conditional statement I am trying to assign them values, then use those values for a query after the conditional statement. var ( number, size, offset, limit string offsetI, limitI uint64 ) // Get the string values for number, size, offset, and limit // ... if size != "" { // Parse the number value numberI, err := strconv.ParseUint(number, 10, 64) if err != nil {...} // Parse the size value limitI,

how to get status of a pod in kubernetes using go-client

北城以北 提交于 2021-02-07 08:20:21
问题 I am trying to delete a pod in my kubernetes cluster, then check its status to see how long does it take for the pod to get down, and up again. I could not find any helpful example for the second part which is getting a specific pod status using go-client. Any help is appreciated. 回答1: You can use Get function to get specific pod information (below examples are getting whole Status struct): pod, _ := clientset.CoreV1().Pods("kubernetes").Get(pod.Name, metav1.GetOptions{}) fmt.Println(pod

how to get status of a pod in kubernetes using go-client

醉酒当歌 提交于 2021-02-07 08:19:11
问题 I am trying to delete a pod in my kubernetes cluster, then check its status to see how long does it take for the pod to get down, and up again. I could not find any helpful example for the second part which is getting a specific pod status using go-client. Any help is appreciated. 回答1: You can use Get function to get specific pod information (below examples are getting whole Status struct): pod, _ := clientset.CoreV1().Pods("kubernetes").Get(pod.Name, metav1.GetOptions{}) fmt.Println(pod

Docker 公司宣布把 Docker Distribution 捐献给了 CNCF

倖福魔咒の 提交于 2021-02-07 08:11:34
文章目录 1 什么是 Docker Distribution 2 为什么要把 Docker Distribution 捐献给 CNCF 3 关于 CNCF 2021年2月4日,负责维护 Docker 引擎的 Justin Cormack 在 Docker 官方博客宣布把 Docker 发行版(Docker Distribution)捐献给了 CNCF,全文如下:​ 我们很高兴地宣布,Docker 已经把 Docker 发行版(Docker Distribution)捐献给了 CNCF。Docker 致力于开源社区和我们许多项目的开放标准,这一举动将确保 Docker 发行版有一个广泛的团队来维护许多注册中心的基础。 如果想及时了解Spark、Hadoop或者HBase相关的文章,欢迎关注微信公众号: iteblog_hadoop 什么是 Docker Distribution 发行版是开放源代码,它是容器仓库(container registry,Docker Hub 的一部分)和许多其他容器仓库的基础。它是容器仓库的参考实现,应用非常广泛,因此是容器生态系统的基础部分。这使得它在 CNCF 新家非常合适。 Docker Distribution 主要重写了用 Python 编写的原始 Registry 代码,这是一个比较早的设计,其中没有使用内容寻址存储。Docker

How do you create a TLS connection to a Cloud SQL database using Go?

本秂侑毒 提交于 2021-02-07 07:51:22
问题 I'm trying to create a TLS connection to a Cloud SQL database but I'm getting the following error when trying to prepare a statement: x509: cannot validate certificate for <cloud sql instance ip> because it doesn't contain any IP SANs Here is my setup code: rootCertPool := x509.NewCertPool() pem, err := ioutil.ReadFile("/path/server-ca.pem") if err != nil { log.Fatal(err) } if ok := rootCertPool.AppendCertsFromPEM(pem); !ok { log.Fatal("Failed to append PEM.") } clientCert := make([]tls