https://github.com/terraform-providers/terraform-provider-github/blob/master/github/config.go ctx := context.Background() insecureClient := &http.Client{ Transport: &http.Transport{ TLSClientConfig: &tls.Config{ InsecureSkipVerify: true, }, }, } ctx = context.WithValue(ctx, oauth2.HTTPClient, insecureClient) client := oauth2.NewClient(ctx, oauth2.StaticTokenSource(&oauth2.Token{ AccessToken: c.Param("accesstoken"), TokenType: "Bearer", })) resp, err := client.Get("https://ory-hydra-login-consent:9020/openid/userinfo") if err != nil { return newHTTPError(400, "InvalidToken", err.Error()) } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { return newHTTPError(400, "InvalidToken", err.Error()) } c.Logger().Debugf("resp: %s", body) var t map[string]interface{} err = json.Unmarshal(body, &t) if err !

繼續閱讀

golang test e2e

httpexpect star 1159 https://github.com/gavv/httpexpect https://github.com/gavv/httpexpect/blob/master/_examples/echo_test.go goconvey https://segmentfault.com/a/1190000014924022 https://github.com/smartystreets/goconvey/ baloo star 652 https://github.com/h2non/baloo frisby star 249 https://github.com/verdverm/frisby apitest star 121 https://github.com/steinfletcher/apitest

繼續閱讀

go mod custome model

https://stackoverflow.com/questions/52079662/go-get-cannot-find-local-packages-when-using-multiple-modules-in-a-repo api/contracts/contract.go package contracts import ( "math/big" "strings" ).... func DeployContract(...) api/contract.go package main import ( "api/contracts" ...) func deployContract(c echo.Context) error { address, tx, token, err := contracts.DeployContract(auth, client) ... } ! Best Import is api/go.mod module api require ( api/contracts v0.0.0 ...) replace ( api/contracts v0.0.0 => ./contracts ...) And api/contracts/go.mod module api/contracts require ( ...) ``` ` `` ``````

繼續閱讀

作者的圖片

Sue boy

Sueboy Can support You

CIO

Taiwan