Use a different executable name when installing by `go get`?

Is it possible to use a different executable name when installing by go get?
I know go build has a -o flag I can use but for consumers of my package.

The context is that company repo mandates naming conventions for the git repos.
something like git.company.com/pkg/GoPkg-Name
But that breaks go get

go: git.company.com/pkg/GoPkg-MyTool.git upgrade => v0.0.0-20210121150345-6241afcc3125
go get: git.company.com/pkg/GoPkg-MyTool.git@v0.0.0-20210121150345-6241afcc3125: parsing go.mod:
	module declares its path as: git.company.com/pkg/mytool
	        but was required as: git.company.com/pkg/GoPkg-MyTool.git

It would be nice to be able to use go get and have it install the tool as mytool without going through more manual steps (mv GoPkg-MyTool mytool for example)

go mod replace …
please google.

I’m 99% sure you didn’t read but that’s fine.

Seems that there is no way to do this for go get.
I’ll live with having people do the rename or just distribute binaries.

I’m 100% sure you didn’t read.

Your reference is dated March 9, 2017. The first published reference to Go modules wasn’t made until February 20, 2018.

FYI for anyone trying this.
Don’t go down the path that I did scratching your head trying to get it to work with mod replace it does not work.
Use the method that https://github.com/bazelbuild/buildtools does and place your tools into named subdirectories that are named by the tool.
I made the mistake of trying to make my repo the name of the tool.
This works with both public and private repo with the exception that private repos you have to add the .git.
So in my example above you can create a mytool subdirectory where the actual tool is located and users install it as

go get git.company.com/pkg/GoPkg-MyTool.git/mytool

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.