Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make go install work consistently for every project #69733

Closed
8 of 27 tasks
yonas opened this issue Oct 1, 2024 · 7 comments
Closed
8 of 27 tasks

Make go install work consistently for every project #69733

yonas opened this issue Oct 1, 2024 · 7 comments

Comments

@yonas
Copy link

yonas commented Oct 1, 2024

Go version

go 1.23

Output of go env in your module/workspace:

N/A

What did you do?

Sometimes it's go install github.com/hello/world@latest, or go install github.com/hello/world/cmd/other@latest or go install github.com/hello/world/v3@latest or it just doesn't work.

What did you see happen?

Often fails.

What did you expect to see?

Should install the program(s).

Proposal: An Official Go Package Manager

Go needs an official package manager. Rust has cargo. Node has npm. Just about every cool new language has it's own package manager and package repository.

Common Features of a Modern Package Manager

Manifest file

  • describe the project in a single file
    • manifest file version
    • project name, description, keywords, categories, version, repo URL, docs URL, homepage URL, license, readme
    • authors names and email addresses
    • dependencies with several attributes
      • version requirements
      • features
      • override location (eg. point to a local copy)
    • features

Common set of commands

  • init [ go mod init should be go init ]
  • add dependencies
  • remove dependencies
  • show tree of dependencies
  • build all executables / libraries with one command (no flags or paths required)
  • build documentation
  • build examples
  • run
  • test
  • bench
  • update
  • search
  • publish
  • install
  • uninstall
  • clean
  • format
  • point to a package repository proxy (eg. a local caching proxy)

Recap

What I'm proposing is that you should only have to type go install github.com/owner/project and everything should automatically work.

Specifically, you should not have to:

  • add /cmd/<some command that's not necessarily "project">
  • add @latest or @<some semver>

Let's create an official package manifest file format that go install can use to find and compile projects.

It would allow putting code in cmd, src, or any other directory, and will proactively search the root directory and ./cmd/<module name specified at the top of go.mod>.

@gabyhelp
Copy link

gabyhelp commented Oct 1, 2024

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@seankhliao
Copy link
Member

see go install pkg/...@latest

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Oct 1, 2024
@yonas
Copy link
Author

yonas commented Oct 1, 2024

@seankhliao Doesn't work for github.com/trufflesecurity/trufflehog@latest

> go install github.com/trufflesecurity/trufflehog@latest
go: github.com/trufflesecurity/trufflehog@latest: module github.com/trufflesecurity/trufflehog@latest found (v3.0.0-rc3+incompatible), but does not contain package github.com/trufflesecurity/trufflehog

@seankhliao
Copy link
Member

That's intentional, major versions are considered different modules, we would not blur the line between them.

@yonas
Copy link
Author

yonas commented Oct 1, 2024

@seankhliao But what's the proper go install for trufflehog? And why do I need to ask? It should be as simple as go install package-name.

@seankhliao
Copy link
Member

It is go install package-name.
Go is consistent in using fully qualified package names everywhere. Introducing different names for install vs import makes things less consistent.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@yonas
Copy link
Author

yonas commented Oct 2, 2024

It is go install package-name.

@seankhliao That hasn't been my experience.

Caution

...Go is consistent in using fully qualified package names everywhere.

Which is the problem I'm describing.

Important

...fully qualified package names...

How about simply pointing to the root of a repo.

For example, golangci-lint is installed via go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
while another will simply be go install github.com/some/package@latest

Proposal: An Official Go Package Manager

Go needs an official package manager. Rust has cargo. Node has npm. Just about every cool new language has it's own package manager and package repository.

Common Features of a Modern Package Manager

Manifest file

  • describe the project in a single file
    • manifest file version
    • project name, description, keywords, categories, version, repo URL, docs URL, homepage URL, license, readme
    • authors names and email addresses
    • dependencies with several attributes
      • version requirements
      • features
      • override location (eg. point to a local copy)
    • features

Common set of commands

  • init [ go mod init should be go init ]
  • add dependencies
  • remove dependencies
  • show tree of dependencies
  • build all executables / libraries with one command (no flags or paths required)
  • build documentation
  • build examples
  • run
  • test
  • bench
  • update
  • search
  • publish
  • install
  • uninstall
  • clean
  • format
  • point to a package repository proxy (eg. a local caching proxy)

Recap

What I'm proposing is that you should only have to type go install github.com/owner/project and everything should automatically work.

Specifically, you should not have to:

  • add /cmd/<some command that's not necessarily "project">
  • add @latest or @<some semver>

Sorry, something went wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants