rename as go-mod-clean
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
c0f80bc42e
commit
c3e3dfd209
10
Makefile
10
Makefile
|
@ -2,24 +2,24 @@ VERSION = $(shell git describe --tags)
|
|||
BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
|
||||
|
||||
run: goimports install
|
||||
go-clean --version
|
||||
go-mod-clean --version
|
||||
|
||||
vet:
|
||||
@GO111MODULE=off go vet
|
||||
@echo this go binary package builds okay
|
||||
|
||||
no-gui: build
|
||||
./go-clean --no-gui
|
||||
./go-mod-clean --no-gui
|
||||
|
||||
build: goimports
|
||||
GO111MODULE=off go build -v \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
||||
build-darwin:
|
||||
GOOS=darwin GOARCH=amd64 GO111MODULE=off go build -v -o go-clean-darwin \
|
||||
GOOS=darwin GOARCH=amd64 GO111MODULE=off go build -v -o go-mod-clean-darwin \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
build-windows:
|
||||
GOOS=windows GOARCH=amd64 GO111MODULE=off go build -v go-clean.exe \
|
||||
GOOS=windows GOARCH=amd64 GO111MODULE=off go build -v go-mod-clean.exe \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
||||
install:
|
||||
|
@ -33,4 +33,4 @@ goimports:
|
|||
# // gofmt -w -r "go.wit.com/gui -> go.wit.com/gui/gui" .
|
||||
|
||||
clean:
|
||||
-rm go-clean
|
||||
-rm -f go-mod-clean go.*
|
||||
|
|
12
README.md
12
README.md
|
@ -1,20 +1,20 @@
|
|||
# go-clean
|
||||
# go-mod-clean
|
||||
|
||||
This is a hack to experiement with trimming unused entries from the go.sum files.
|
||||
Since go.sum files need to be recursively processed, this attempts to remove
|
||||
unused entries. There are all sorts of real world reasons on why this
|
||||
needs to be done sometimes.
|
||||
|
||||
* go-clean tries to remove uneeded entries from the go.sum file.
|
||||
* You must run go-clean in ~/go/src for this to work.
|
||||
* go-mod-clean tries to remove uneeded entries from the go.sum file.
|
||||
* You must run go-mod-clean in ~/go/src for this to work.
|
||||
|
||||
# Install go-clean
|
||||
# Install go-mod-clean
|
||||
|
||||
go install go.wit.com/apps/go-clean@latest
|
||||
go install go.wit.com/apps/go-mod-clean@latest
|
||||
|
||||
# How it works
|
||||
|
||||
go-clean is very simple. It will run 'go build' with GO111MODULE=off. In this mode,
|
||||
go-mod-clean is very simple. It will run 'go build' with GO111MODULE=off. In this mode,
|
||||
go will compile directly based on the 'import' paths. It simply parses the errors
|
||||
from 'go build' and makes sure the appropriate entries are in the go.sum file.
|
||||
|
||||
|
|
4
argv.go
4
argv.go
|
@ -12,12 +12,12 @@ type args struct {
|
|||
}
|
||||
|
||||
func (args) Version() string {
|
||||
return "go-clean " + VERSION + " Built on " + BUILDTIME
|
||||
return "go-mod-clean " + VERSION + " Built on " + BUILDTIME
|
||||
}
|
||||
|
||||
func (a args) Description() string {
|
||||
return `
|
||||
go-clean will try to verify your go.* files are using the newest package versions
|
||||
go-mod-clean will try to verify your go.* files are using the newest package versions
|
||||
|
||||
* Recreate go.* with 'go mod init' and 'go mod tidy'
|
||||
* Check that the most recent master branch versions are used
|
||||
|
|
4
control
4
control
|
@ -1,6 +1,6 @@
|
|||
Source: go-clean
|
||||
Source: go-mod-clean
|
||||
Build-Depends: golang, protoc-gen-go, autogenpb, golang-golang-x-tools
|
||||
Package: go-clean
|
||||
Package: go-mod-clean
|
||||
Maintainer: Jeff Carr <jcarr@wit.com>
|
||||
Architecture: amd64
|
||||
Depends:
|
||||
|
|
14
main.go
14
main.go
|
@ -20,7 +20,7 @@ var forge *forgepb.Forge
|
|||
var check *gitpb.Repo
|
||||
|
||||
func main() {
|
||||
log.Info("go-clean version", VERSION, "built on", BUILDTIME)
|
||||
log.Info("go-mod-clean version", VERSION, "built on", BUILDTIME)
|
||||
pp = arg.MustParse(&argv)
|
||||
|
||||
// load the ~/.config/forge/ config
|
||||
|
@ -35,18 +35,18 @@ func main() {
|
|||
log.Info("this directory isn't in a golang project (not in ~/go/src nor a go.work file)")
|
||||
os.Exit(-1)
|
||||
}
|
||||
log.Info("starting go-clean for", check.GoPath)
|
||||
log.Info("starting go-mod-clean for", check.GoPath)
|
||||
log.Info("go src dir is set to", forge.GetGoSrc())
|
||||
|
||||
if argv.Recursive {
|
||||
if forge.IsGoWork() {
|
||||
var warning []string
|
||||
warning = append(warning, "go-clean --recursive may not work unless you are in ~/go/src")
|
||||
warning = append(warning, "go-mod-clean --recursive may not work unless you are in ~/go/src")
|
||||
warning = append(warning, "you can continue anyway, but it hasn't been tested as much.")
|
||||
simpleStdin(true, warning)
|
||||
}
|
||||
var warning []string
|
||||
warning = append(warning, "go-clean will recreate go.mod and go.sum")
|
||||
warning = append(warning, "go-mod-clean will recreate go.mod and go.sum")
|
||||
warning = append(warning, "because you have selected --recursive")
|
||||
warning = append(warning, "this will redo _every_ repo. This is probably fine.")
|
||||
warning = append(warning, fmt.Sprintf("You have %d total repositories in %s", forge.Repos.Len(), forge.GetGoSrc()))
|
||||
|
@ -61,7 +61,7 @@ func main() {
|
|||
simpleStdin(false, warning)
|
||||
// purgeGoCaches()
|
||||
} else {
|
||||
simpleStdin(true, []string{"go-clean will recreate go.mod and go.sum"})
|
||||
simpleStdin(true, []string{"go-mod-clean will recreate go.mod and go.sum"})
|
||||
}
|
||||
|
||||
// re-create go.sum and go.mod
|
||||
|
@ -104,11 +104,11 @@ func findPwdRepo() *gitpb.Repo {
|
|||
|
||||
func okExit(thing string) {
|
||||
log.Info(thing, "ok")
|
||||
log.Info("Finished go-clean on", check.GetGoPath(), "ok")
|
||||
log.Info("Finished go-mod-clean on", check.GetGoPath(), "ok")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func badExit(err error) {
|
||||
log.Info("go-clean failed: ", err, forge.GetGoSrc())
|
||||
log.Info("go-mod-clean failed: ", err, forge.GetGoSrc())
|
||||
os.Exit(-1)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue