go fmt and CI (e.g. gitlab)

789 views
Skip to first unread message

Jérôme LAFORGE

unread,
Feb 19, 2018, 6:44:36 AM2/19/18
to golang-nuts
Hello Gophers,
Has any one of you setted up the validation of format (goimports, go fmt) into Gitlab CI?
My goal is to reject the commit that doesn't respect the Go's format.

Thx in adv
BR

Stéphane Jeandeaux

unread,
Feb 19, 2018, 2:35:48 PM2/19/18
to Jérôme LAFORGE, golang-nuts

Hi Jerome,

You can take a look at git hooks https://golang.org/misc/git/pre-commit.

Code:
test -z "$(gofmt -s -l $(find . -name '*.go' -type f -print) | tee /dev/stderr)"

Thanks and regards,
Stephane Jeandeaux.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jérôme LAFORGE

unread,
Feb 20, 2018, 11:06:19 AM2/20/18
to golang-nuts
Thx, it is perfect.
Reply all
Reply to author
Forward
0 new messages