2019/03/27

gin,appengine,graphql test


gin+GAE+graphql のテスト下記で行けった。


appEngineTestInstance
->instance.NewRequest
gin.Context(request)
context.Set(key value)

```
ins, _ := aetest.NewInstance(nil)
req, _ := ins.NewRequest("", "", nil)

var context *gin.Context
context = &gin.Context{Request: req}
b, _ := json.Marshal(x.y{z: "1"})
context.Set("key", b)
```

2019/03/18

2019/03/05

Removing packages installed with go get

juse delete the source and package
麻烦,要是有一个命令就好了,找一下

It's safe to just delete the source directory and compiled package file. Find the source directory under $GOPATH/src and the package file under $GOPATH/pkg/<architecture>, for example: $GOPATH/pkg/windows_amd64.


example
go get github.com/golang/mock/mockgen


go clean -i github.com/golang/mock/mockgen

The -i flag causes clean to remove the corresponding installed
archive or binary (what 'go install' would create).

The -n flag causes clean to print the remove commands it would execute,
but not run them.

The -r flag causes clean to be applied recursively to all the
dependencies of the packages named by the import paths.


The -x flag causes clean to print remove commands as it executes them.

不知道安装的packagePath的话,找一下$GOPATH/pkg/windows_amd64啥的

2019/03/04

go gin validator omitempty

細かくて面倒

・Pointer推奨、nilとZeroValueを区別するため
・bindingはpointerに対しても有効
・omtiemptyが必須ね。。

type XXXRequest struct {
Adate *time.Time `json:"aDate,omitempty" time_format:"2006-01-02”` 
B *float64`json:"b,omitempty" binding:"omitempty,min=-90,max=90”` 
C *float64 `json:"c,omitempty" binding:"omitempty,min=-180,max=180”`
}