Skip to content

Commit

Permalink
Merge pull request #661 from uber/standardize_goimports_formatting
Browse files Browse the repository at this point in the history
Standardize formatting to use goimports instead of gofmt
  • Loading branch information
tejaswiagarwal authored Oct 17, 2019
2 parents 5ac2add + fe7fa58 commit cb60d7d
Show file tree
Hide file tree
Showing 80 changed files with 146 additions and 104 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ cyclo-check:
lint: check-licence eclint-check
@rm -f lint.log
@echo "Checking formatting..."
@gofmt -d -s $(PKG_FILES) 2>&1 | $(FILTER_LINT) | tee -a lint.log
@$(GOIMPORTS)/goimports -d $(PKG_FILES) 2>&1 | $(FILTER_LINT) | tee -a lint.log
@echo "Installing test dependencies for vet..."
@go test -i $(PKGS)
@echo "Checking printf statements..."
Expand Down Expand Up @@ -115,7 +115,7 @@ generate:
@$(GOBINDATA)/go-bindata -pkg config -nocompress -modtime 1 -prefix config -o config/production.gen.go $(ENV_CONFIG)
@./node_modules/.bin/uber-licence --file "production.gen.go" --dir "config" > /dev/null
@$(GOBINDATA)/go-bindata -pkg templates -nocompress -modtime 1 -prefix codegen/templates -o codegen/template_bundle/template_files.go codegen/templates/...
@gofmt -w -e -s "codegen/template_bundle/template_files.go"
@$(GOIMPORTS)/goimports -w -e "codegen/template_bundle/template_files.go"
@PATH=$(GOGOSLICK):$(YARPCGO):$(GOIMPORTS):$(GOMOCK):$(PATH) bash ./scripts/generate.sh

.PHONY: check-generate
Expand Down
9 changes: 0 additions & 9 deletions codegen/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -1307,22 +1307,13 @@ func PrintGenLine(

// FormatGoFile reformat the go file imports
func FormatGoFile(filePath string) error {
gofmtCmd := exec.Command("gofmt", "-s", "-w", "-e", filePath)
gofmtCmd.Stdout = os.Stdout
gofmtCmd.Stderr = os.Stderr

if err := gofmtCmd.Run(); err != nil {
return errors.Wrapf(err, "failed to gofmt file: %q", filePath)
}

goimportsCmd := exec.Command("goimports", "-w", "-e", filePath)
goimportsCmd.Stdout = os.Stdout
goimportsCmd.Stderr = os.Stderr

if err := goimportsCmd.Run(); err != nil {
return errors.Wrapf(err, "failed to goimports file: %q", filePath)
}

return nil
}

Expand Down
4 changes: 2 additions & 2 deletions codegen/runner/pre-steps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ for config_file in ${config_files}; do
done
done

gofmt -w -s "$BUILD_DIR/gen-code/"

end=$(date +%s)
runtime=$((end-start))
echo "Generated structs : +$runtime"
Expand Down Expand Up @@ -200,6 +198,8 @@ $(find "${target_dirs[@]}" -name "*.go" | \
)
"$EASY_JSON_BINARY" -all -- "${thriftrw_gofiles[@]}"

goimports -w "$BUILD_DIR/gen-code/"

end=$(date +%s)
runtime=$((end-start))
echo "Generated structs : +$runtime"
2 changes: 1 addition & 1 deletion codegen/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

"github.com/pkg/errors"
"github.com/uber/zanzibar/codegen"
"github.com/uber/zanzibar/runtime"
zanzibar "github.com/uber/zanzibar/runtime"
)

type stackTracer interface {
Expand Down
2 changes: 1 addition & 1 deletion codegen/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
tmpl "text/template"

"github.com/pkg/errors"
"github.com/uber/zanzibar/codegen/template_bundle"
templates "github.com/uber/zanzibar/codegen/template_bundle"
)

// AssetProvider provides access to template assets
Expand Down
50 changes: 25 additions & 25 deletions codegen/template_bundle/template_files.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion examples/example-gateway/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import (
"go.uber.org/zap"

"context"
"github.com/uber/zanzibar/runtime"

zanzibar "github.com/uber/zanzibar/runtime"
)

// AppOptions defines the custom application func
Expand Down
3 changes: 2 additions & 1 deletion examples/example-gateway/app/demo/endpoints/abc/abc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package abc

import (
"context"
"github.com/uber/zanzibar/runtime"

zanzibar "github.com/uber/zanzibar/runtime"

module "github.com/uber/zanzibar/examples/example-gateway/build/app/demo/endpoints/abc/module"
workflow "github.com/uber/zanzibar/examples/example-gateway/build/app/demo/endpoints/abc/workflow"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cb60d7d

Please sign in to comment.