#gow keeps changing my go.mod and requiring me to rerun go mod tidy

46 messages · Page 1 of 1 (latest)

marble pagoda
#

I've created a go gin app with @nx-go and it's using go version 1.18.5

when I save a file my application stops and asks me to run go mod tidy again, which prevents gow from working properly as my local development environment.

What can I do to fix this situation? It's harder to developed like this.

muted blaze
#

What is @nx-go? What is gow?

marble pagoda
muted blaze
#

I've not heard of either of those, but my guess is you're adding imports and then go wants you to sync up your module.
Since gow is presumably trying to rebuild on file change, it's probably yelling at you then

#

Generally you would just tidy before a build, but gow is likely trying to build after each save

marble pagoda
#

maybe gow is able to configure build?

#

Like enablig it to somehow to run go mod tidy after every build

#

actually, before

muted blaze
#

Not from what I can see

#

You could try pre-getting any deps you need

marble pagoda
#

How so?

muted blaze
#

I'm guessing the problem is when you add a new dep, so you should be able to just get them before you run gow

#

Otherwise it might be a general gow issue, I'm not entirely sure

marble pagoda
#

Check this out:

#

when I run go mod tidy, this happens to my go.mod:


module bnoti

go 1.18

require (
    github.com/gin-gonic/gin v1.8.2
    github.com/nikoksr/notify v0.38.0
    gorm.io/driver/postgres v1.4.6
    gorm.io/gorm v1.24.3
)

require (
    github.com/gin-contrib/sse v0.1.0 // indirect
    github.com/go-playground/locales v0.14.1 // indirect
    github.com/go-playground/universal-translator v0.18.0 // indirect
    github.com/go-playground/validator/v10 v10.11.1 // indirect
    github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible // indirect
    github.com/goccy/go-json v0.10.0 // indirect
    github.com/jackc/pgpassfile v1.0.0 // indirect
    github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
    github.com/jackc/pgx/v5 v5.2.0 // indirect
    github.com/jinzhu/inflection v1.0.0 // indirect
    github.com/jinzhu/now v1.1.5 // indirect
    github.com/json-iterator/go v1.1.12 // indirect
    github.com/leodido/go-urn v1.2.1 // indirect
    github.com/mattn/go-isatty v0.0.17 // indirect
    github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
    github.com/modern-go/reflect2 v1.0.2 // indirect
    github.com/pelletier/go-toml/v2 v2.0.6 // indirect
    github.com/pkg/errors v0.9.1 // indirect
    github.com/technoweenie/multipartstreamer v1.0.1 // indirect
    github.com/ugorji/go/codec v1.2.8 // indirect
    golang.org/x/crypto v0.5.0 // indirect
    golang.org/x/net v0.5.0 // indirect
    golang.org/x/sync v0.1.0 // indirect
    golang.org/x/sys v0.4.0 // indirect
    golang.org/x/text v0.6.0 // indirect
    google.golang.org/protobuf v1.28.1 // indirect
    gopkg.in/yaml.v2 v2.4.0 // indirect
)

#

then I run my gin App and it runs ok...

But as soon as I save, my go.mod changes to this:

module bnoti

go 1.18

require (
    github.com/gin-gonic/gin v1.8.2
    github.com/nikoksr/notify v0.38.0
    gorm.io/driver/postgres v1.4.6
    gorm.io/gorm v1.24.3
)

require (
    github.com/go-playground/locales v0.14.1 // indirect
    github.com/goccy/go-json v0.10.0 // indirect
    github.com/mattn/go-isatty v0.0.17 // indirect
    github.com/ugorji/go/codec v1.2.8 // indirect
)

#

And then it stops working

muted blaze
#

Sounds like something is hijacking your go.mod
Not sure if it's gow, but seems like it might be.

marble pagoda
#

Actually after further inspection

#

when I save, generally, without running via gow my go.mod changes

#

yeah, pretty much I save a .go file and bam, it changes

muted blaze
#

Seems like something weird is happening with your editor perhaps

marble pagoda
#

Ok, I removed the go extension from vscode

#

And I think it works now

#

yeah, works normally

muted blaze
#

Might have just needed a restart, sometimes gopls can get out of whack with the editor

#

editor restart, to clarify

marble pagoda
#

What does gopls do?

muted blaze
#

It's the language server, so essentially it's how the editor shows you compilation errors, etc.

marble pagoda
#

Ok thanks for helping me figure it out.

The problem was that I am using gvm and the vscode extension did not detect the go version I was using

muted blaze
#

Oh, gotcha

#

Also haven't used gvm before

marble pagoda
#

really useful tool to be honest

#

Thanks for your help again!

muted blaze
#

Never had a need for multiple versions of the toolchain 😅
And go can install other versions of itself already.

But yeah, no prob!

marble pagoda
muted blaze
#

Granted, then you need to call it as gox.y.z instead of just go

#

But then I've never really needed multiple versions, I just sometimes download tip versions to test new features

marble pagoda
#

I have a "legacy" system that uses go 1.13 and another new one using 1.16

#

So gvm allows me to set a default

#

and I don't have to handle selecting the version

#

at least handle selecting the version on the execution script alone

#

but it's interesting to know that, thanks

muted blaze
#

Fair enough, yeah

rose pollen
#

Why would one need 1.13 with the backwards compat promise?