#gow keeps changing my go.mod and requiring me to rerun go mod tidy
46 messages · Page 1 of 1 (latest)
What is @nx-go? What is gow?
gow:
https://github.com/mitranim/gow
Is a go watch tool
@nx-go:
https://github.com/nx-go/nx-go
it is just a helper to create a go project compatible with nx, which is a build system
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
maybe gow is able to configure build?
Like enablig it to somehow to run go mod tidy after every build
actually, before
How so?
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
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
Sounds like something is hijacking your go.mod
Not sure if it's gow, but seems like it might be.
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
Seems like something weird is happening with your editor perhaps
Ok, I removed the go extension from vscode
And I think it works now
yeah, works normally
Might have just needed a restart, sometimes gopls can get out of whack with the editor
editor restart, to clarify
What does gopls do?
It's the language server, so essentially it's how the editor shows you compilation errors, etc.
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
Never had a need for multiple versions of the toolchain 😅
And go can install other versions of itself already.
But yeah, no prob!
Really? How can it install other versions?
go install golang.org/dl/gox.y.z@latest
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
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
Fair enough, yeah
Why would one need 1.13 with the backwards compat promise?