Alternatively, setting GOFLAGS=-mod=readonly may help depending on what
go tool subcommands you are running.

On Wed, 2019-03-06 at 12:45 -0800, Evan Borgstrom wrote:
> Our CI pipeline already does `git status -s -uno` and if there is any
> output prints the diff & exits.
> 
> However, this happens at the END of a build (after running lint,
> build,
> test, doc generation, etc), which means you could wait ~minutes
> before you
> get the feedback.  We have specialized checks for other languages
> during
> the lint stage that ensures this very early in the build so we don't
> waste
> time, and I'm looking for something similar with go.
> 
> EB
> 
> On Wed, Mar 6, 2019 at 12:35 PM Dan Kortschak <d...@kortschak.io>
> wrote:
> 
> > 
> > Can you just check that the vcs diffs them as no diff?
> > 
> > e.g.
> > ```
> > if [ -n "$(git diff -- go.mod go.sum)" ]; then
> >         git diff -- go.mod go.sum
> >         exit 1
> > fi
> > ```
> > 
> > On Wed, 2019-03-06 at 11:07 -0800, eborgst...@nerdwallet.com wrote:
> > > 
> > > Hi fellow Gophers,
> > > 
> > > My company has a requirement in our CI builds that no files which
> > > are
> > > part
> > > of the repository are modified as part of the build.
> > > 
> > > For our Go builds this bites us sometimes because there are
> > > circumstances
> > > where someone can push a commit where when `go build`/`go test`
> > > are
> > > called
> > > the go.mod/go.sum files end up being modified.
> > > 
> > > It's generally always an easy fix, but what I'm looking for is a
> > > way
> > > to
> > > provide early & explicit feedback to our Gophers.
> > > 
> > > I've been through all the CLI docs but I can't find anything
> > > which
> > > asserts
> > > that go.mod & go.sum are in sync without actually changing them.
> > > 
> > > Does anyone have any suggestions here?
> > > 
> > > Thanks!
> > > EB
> > > 

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to