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

proposal: divide go module dependencies into two categories: require and testRequire #42766

Closed
kaka19ace opened this issue Nov 22, 2020 · 3 comments

Comments

@kaka19ace
Copy link

kaka19ace commented Nov 22, 2020

dividing deps into two categories:

  • "dependences" at runtime;
  • "devDependences" during development.
    i think it's a clean way of dependency management.

For examples in Python/Node.js:

python: setup.py -> tests_require
eg: https://github.com/psf/requests/blob/3.0/setup.py#L126

node.js: package.json -> devDependencies
eg: https://github.com/expressjs/express/blob/4.18/package.json#L62

expected layout

go.mod:

module github.com/{namespace}/dbdriver-wrapper

go 1.13

// for biz
require (
   ...
)

// for unittest
testRequire (
    github.com/stretchr/testify v1.6.1
    github.com/mattn/go-sqlite3. v2.0.3
)

@gopherbot gopherbot added this to the Proposal milestone Nov 22, 2020
@kaka19ace kaka19ace changed the title proposal: divide go module dependencies into two categories: release and development proposal: divide go module dependencies into two categories: require and testRequire Nov 22, 2020
@fzipp
Copy link
Contributor

fzipp commented Nov 22, 2020

Do you propose any behavioural differences between the two or is this just a cosmetic grouping?

Python and Node need to know the difference between the two in order to decide what becomes part of the build artifacts, while Go does not.

@DeedleFake
Copy link

To clarify why Go doesn't, it's because, unlike with NPM and similar languages, the go.mod file does not specify a module's dependencies. It specifies what versions of dependencies are needed. The import statements in the Go files are the ones that actually specify dependencies, so test dependencies are automatically sorted by virtue of being imported only from test files.

@mvdan
Copy link
Member

mvdan commented Nov 23, 2020

Duplicate of #26913.

@mvdan mvdan closed this as completed Nov 23, 2020
@golang golang locked and limited conversation to collaborators Nov 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants