我有一个这样的控制器功能......
func GetMaterialByFilter(c *gin.Context) {
queryParam := weldprogs.QueryParam{}
c.BindQuery(&queryParam)
materialByFilter, getErr := services.WeldprogService.GetMaterialByFilter(&queryParam)
if getErr != nil {
//TODO : Handle user creation error
c.JSON(getErr.Status, getErr)
return
}
c.JSON(http.StatusOK, materialByFilter)
}
Run Code Online (Sandbox Code Playgroud)
QueryParam 结构是这样的..
type QueryParam struct {
Basematgroup_id []string `form:"basematgroup_id"`
License_id []string `form:"license_id"`
Diameter_id []string `form:"diameter_id"`
Gasgroup_id []string `form:"gasgroup_id"`
Wiregroup_id []string `form:"wiregroup_id"`
Wiremat_id []string `form:"wiremat_id"`
}
Run Code Online (Sandbox Code Playgroud)
我的测试功能是这样的..
func TestGetMaterialByFilter(t *testing.T) {
w := httptest.NewRecorder()
c, _ := gin.CreateTestContext(w)
GetMaterialByFilter(c)
assert.Equal(t, 200, w.Code)
var got gin.H
err := json.Unmarshal(w.Body.Bytes(), &got)
if …Run Code Online (Sandbox Code Playgroud) 我是谷歌云平台的新手,我正在尝试谷歌云函数,但它表现出非常奇怪的行为。我正在尝试运行以下代码:
exports.helloPubSub = (event, context) => {
const pubsubMessage = event.data;
console.log(event.data.attributes);
console.log(Buffer.from(pubsubMessage, 'base64').toString());
};
Run Code Online (Sandbox Code Playgroud)
但是当我点击创建一个函数时,部署失败并且在尝试了 8-9 次之后几乎没有部署。它抛出的错误是
Deployment failure:
Build failed: {"cacheStats": [{"status": "MISS", "hash": "0bb4aa23414dd82b8643cb2c86b5a55af031b22701fbe364a88ea6e61ad481a4", "type": "docker_layer_cache", "level": "global"}, {"status": "HIT", "hash": "0bb4aa23414dd82b8643cb2c86b5a55af031b22701fbe364a88ea6e61ad481a4", "type": "docker_layer_cache", "level": "project"}]}
Run Code Online (Sandbox Code Playgroud)
这是 Google Cloud Platform 中的错误还是我做错了什么?如果我做错了什么,那么我甚至不能部署它一次。
任何帮助将不胜感激。非常感谢!
我正在尝试为我的谷歌云功能构建 CI/CD 管道。我所知道的是,我有带有 gcloud 和 git 的本地开发环境。我在本地环境中编写代码并拥有 cloudbuilds.yaml 文件。编写代码后,我将其推送到我有构建触发器的 Google 源代码库。它构建函数并部署它。
现在我也想要一些测试文件。这意味着每当我将它推送到源存储库时,它也应该运行测试并构建我的 main.py 文件,然后部署它。我拥有的 cloudbuild.yaml 文件是
steps:
- name: 'gcr.io/cloud-builders/gcloud'
args:
- functions
- deploy
- FunctionName
- --runtime=python37
- --source=.
- --entry-point=function
- --trigger-topic=topic_name
- --region=europe-west3
Run Code Online (Sandbox Code Playgroud) gcloud google-cloud-functions google-source-repositories google-cloud-build
我有这个功能。
func (s *eS) Post(param *errorlogs.Q) (*errorlogs.Error, *errors.RestErr) {
//sub := q.Get("sub")
s.mu.Lock()
utime := int32(time.Now().Unix())
// Open our jsonFile
jsonFile, errFile := getlist(param.Id)
// if we os.Open returns an error then handle it
if errFile != nil {
return nil, errFile
}
jsonFile, err := os.Open(dir + "/File.json")
// if we os.Open returns an error then handle it
if err != nil {
return nil, errors.NewNotFoundError("Bad File request")
}
// read our opened jsonFile as a byte array.
byteValue, …Run Code Online (Sandbox Code Playgroud)