我正在使用 circleCI 来部署生产或暂存环境。我想对与每个环境对应的每个分支的上下文使用相同的作业,因为我不喜欢为每个环境编写相同的代码。
我想像下面这样写。
version: 2
jobs:
deploy:
docker:
- image: google/cloud-sdk
steps:
- checkout
- run: <deploying commands>
workflows:
version: 2
deploy:
jobs:
- deploy:
filters:
branches:
only:
- master
context: production
- deploy:
filters:
branches:
only:
- develop
context: staging
Run Code Online (Sandbox Code Playgroud) 比如这种情况下,err 变量很快就会当场完成它的作用,所以我认为没有必要定义多个名称。
package main
func main() {
foo, errFoo := foo()
if errFoo != nil {
panic(errFoo)
}
bar, errBar := bar()
if errBar != nil {
panic(errFoo)
}
}
Run Code Online (Sandbox Code Playgroud)
所以我将代码更改如下。
package main
func main() {
foo, err := foo()
if err != nil {
panic(err)
}
bar, err := bar()
if err != nil {
panic(err)
}
}
Run Code Online (Sandbox Code Playgroud)
你们都遵守什么规矩?