go

cloudtasks.CreateTask fails: `lacks IAM permission “cloudtasks.tasks.create”` even though my account has that permission

让人想犯罪 __ 提交于 2021-02-11 16:42:23
问题 I'm following the Creating HTTP Target tasks guide. When I run the code posted below I get this error: cloudtasks.CreateTask: rpc error: code = PermissionDenied desc = The principal (user or service account) lacks IAM permission "cloudtasks.tasks.create" for the resource "projects/my_project/locations/europe-west1/queues/my_queue" (or the resource may not exist). I have signed in with gcloud auth login my@email.com . my@email.com has the following permissions set by my custom cloud task role:

Golang GraphQL MongoDB Struggling to get date and id out of the Database

喜欢而已 提交于 2021-02-11 15:40:51
问题 I am new to Golang and Graphql so I probably messed a lot of the configuration up but I am struggling to get values returned from my database using the GraphQL API I created. Whenever I query my database using the GraphQL API I created in Golang It throws the error cannot decode UTC datetime into a string type and struggles to get the id out. Here is my GrapqhQL schema: type User { _id: ID! username: String! passwordHash: String! email: String! userInfo: userStats profileStats: profileInfo }

Necessity of bson struct tag when using with MongoDB go client

本小妞迷上赌 提交于 2021-02-11 15:31:40
问题 I am watching a tutorial on how to create Go restful APIs that use MongoDB for persistence (this one to be more precise). The instructor is using in his model (struct) both json and bson tags, something like type NoteUpdate struct { ID string `json:"id,omitempty" bson:"_id,omitempty"` Title string `json:"title" bson:"title,omitempty"` Content string `json:"content" bson:"content,omitempty"` ChangedAt int64 `json:"changed_at" bson:"changed_at"` } However the official go driver example does not

Necessity of bson struct tag when using with MongoDB go client

别来无恙 提交于 2021-02-11 15:30:22
问题 I am watching a tutorial on how to create Go restful APIs that use MongoDB for persistence (this one to be more precise). The instructor is using in his model (struct) both json and bson tags, something like type NoteUpdate struct { ID string `json:"id,omitempty" bson:"_id,omitempty"` Title string `json:"title" bson:"title,omitempty"` Content string `json:"content" bson:"content,omitempty"` ChangedAt int64 `json:"changed_at" bson:"changed_at"` } However the official go driver example does not

Kubernetes系列之kubeadm升级1.14.1到1.15.1版本

余生颓废 提交于 2021-02-11 15:25:51
升级之前 运行的版本为1.14的kubeadm Kubernetes集群 确保备份所有重要组件,例如存储在数据库中的应用程序级状态。kubeadm upgrade 不会触及您的工作负载,只会触及Kubernetes内部的组件,但备份始终是最佳实践。 附加信息 升级后重新启动所有容器,因为容器规范哈希值已更改。 您只能从一个MINOR版本升级到下一个MINOR版本,或者在同一个MINOR的PATCH版本之间升级。也就是说,升级时不能跳过MINOR版本。例如,您可以从1.y升级到1.y + 1,但不能从1.y升级到1.y + 2。 升级顺序: master --> node 升级前 # kubectl get nodes NAME STATUS ROLES AGE VERSION huoban -k8s-master01 Ready master 28d v1. 14.1 huoban -k8s-master02 Ready master 28d v1. 14.1 huoban -k8s-master03 Ready master 28d v1. 14.1 huoban -k8s-node01 Ready <none> 28d v1. 14.1 huoban -k8s-node02 Ready <none> 28d v1. 14.1 准备工作 1 、编译自定义kubeadm

A complex update in GORM

非 Y 不嫁゛ 提交于 2021-02-11 14:33:01
问题 I have a model in GORM with Postgres as database. The model is like this type Country struct { gorm.Model Name string Population int64 Regions []Region } type Region struct { gorm.Model Name string Cities []City CountryID uint `sql:"type:bigint REFERENCES countries(id) ON DELETE CASCADE" json:"-"` } type City struct { gorm.Model Name string Comment string RegionID uint `sql:"type:bigint REFERENCES regions(id) ON DELETE CASCADE" json:"-"` } When I create a new record from model, I invoke

How to categorize list of objects based on a parameter

我们两清 提交于 2021-02-11 14:32:46
问题 I have a list of objects with this definition: type MyObject struct { ID int `json:"id"` Level int `json:"level"` CityID int `json:"city_id"` } I want to categorize them based on CityID in order to get a list of lists where each inner list's items have the same CityID . For example, if I have the following list: [ MyObject {ID: 1, Level: 12, CityID: 7}, MyObject {ID: 2, Level: 15, CityID: 2}, MyObject {ID: 3, Level: 55, CityID: 4}, MyObject {ID: 4, Level: 88, CityID: 7}, MyObject {ID: 5,

Why is string pointer in golang behavior counter-intuitive in range-loop?

北慕城南 提交于 2021-02-11 14:31:24
问题 With this code: https://play.golang.org/p/tCm1W-K-6ob This code would print: [c c c] , but [a b c] is excepted. type A struct { a *string } func f() { slist := []string{"a", "b", "c"} list := make([]*A, len(slist)) for i, v := range slist { item := &A{ a: &v, } list[i] = item } fmt.Printf("[%s %s %s]", *list[0].a, *list[1].a, *list[2].a) } func main() { f() } Why the list is not ["a", "b", "c"] ? What happened to the range or the &string ? 回答1: https://play.golang.org/p/utJrUmxeqfh package

Why is string pointer in golang behavior counter-intuitive in range-loop?

久未见 提交于 2021-02-11 14:28:19
问题 With this code: https://play.golang.org/p/tCm1W-K-6ob This code would print: [c c c] , but [a b c] is excepted. type A struct { a *string } func f() { slist := []string{"a", "b", "c"} list := make([]*A, len(slist)) for i, v := range slist { item := &A{ a: &v, } list[i] = item } fmt.Printf("[%s %s %s]", *list[0].a, *list[1].a, *list[2].a) } func main() { f() } Why the list is not ["a", "b", "c"] ? What happened to the range or the &string ? 回答1: https://play.golang.org/p/utJrUmxeqfh package

After go install the import doesn't recognize the package

若如初见. 提交于 2021-02-11 14:17:57
问题 Hi I'm pretty new at Golang, after install it I would like to use the next package in my project: https://github.com/gin-gonic/gin After I created my project, I did the next command to install gingonic: go get -u github.com/gin-gonic/gin But the import is not recognized inside my project, I understand that it's something related with my GOROOT, but I wasn't able to solve the issue. The next are are my Go env variables: GO111MODULE="on" GOARCH="amd64" GOBIN="" GOCACHE="/Users/rpantoja/Library