You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
https://github.com/wkaluza/go_issue_subdir contains an essentially identical app wise_app_subdir, but the directory tree (including go.mod and go.sum) has been placed in a subdirectory subdir.
Both repositories contain a default branch main and a semver tag v0.0.1.
The command go install github.com/wkaluza/go_issue_root/cmd/[email protected] works fine and places the executable wise_app_root in $GOPATH/bin. Attempting to run github.com/wkaluza/go_issue_subdir/subdir/cmd/[email protected] fails.
Curiously, installing a non-semver tag does not show this behaviour and works for both repos. Likewise, installations using "latest", a branch name or the commit digest (SHA-1) are not affected by the project structure. The following script can be used to replicate the failure:
#!/usr/bin/env bash
set -euo pipefail
function clean_test_env {
rm -f $GOPATH/bin/wise_app_root
rm -f $GOPATH/bin/wise_app_subdir
go clean -cache -modcache -testcache
}
function run_tests {
local revision1="$1"
local revision2="${2:-$revision1}"
local URL_ROOT="github.com/wkaluza/go_issue_root/cmd/wise_app_root"
local URL_SUBDIR="github.com/wkaluza/go_issue_subdir/subdir/cmd/wise_app_subdir"
echo ""
echo "Install app from repo root directory (revision: $revision1)"
echo "go install $URL_ROOT@$revision1"
echo ""
clean_test_env
go install "$URL_ROOT@$revision1"
$GOPATH/bin/wise_app_root
echo ""
echo "Install app from repo subdirectory (revision: $revision2)"
echo "go install $URL_SUBDIR@$revision2"
echo ""
clean_test_env
go install "$URL_SUBDIR@$revision2"
$GOPATH/bin/wise_app_subdir
}
function main {
### All of these work fine:
# run_tests latest
# run_tests main
# run_tests \
# 3f2f5eb664072317111c17ec80aca61e04f2d943 \
# 60038133a59943847cd9a830f218ca3491943c5b
# run_tests branch_not_main
# run_tests tag_not_semver
### A semver tag fails for the subdir case
run_tests v0.0.1
echo Success
}
# Entry point
main
What did you expect to see?
I expected go install to work with semver-tagged revisions irrespective of project structure and install the executable wise_app_subdir in $GOPATH/bin.
What did you see instead?
$ go install github.com/wkaluza/go_issue_subdir/subdir/cmd/[email protected]
go: downloading github.com/wkaluza/go_issue_subdir v0.0.1
go install: github.com/wkaluza/go_issue_subdir/subdir/cmd/[email protected]: module github.com/wkaluza/[email protected] found, but does not contain package github.com/wkaluza/go_issue_subdir/subdir/cmd/wise_app_subdir
The text was updated successfully, but these errors were encountered:
If a module is defined in a subdirectory within the repository, that is, the module subdirectory portion of the module path is not empty, then each tag name must be prefixed with the module subdirectory, followed by a slash.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes (
go1.17beta1-2430-g6c36c332fe
)What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I attempted to run
go install
of a package whose module is located in a subdirectory of the git repo.I created two specimen repositories to illustrate the problem:
wise_app_root
with the canonicalcmd
+pkg
directory structure.wise_app_subdir
, but the directory tree (includinggo.mod
andgo.sum
) has been placed in a subdirectorysubdir
.Both repositories contain a default branch
main
and a semver tagv0.0.1
.The command
go install github.com/wkaluza/go_issue_root/cmd/[email protected]
works fine and places the executablewise_app_root
in$GOPATH/bin
. Attempting to rungit.freesoso.sbs/wkaluza/go_issue_subdir/subdir/cmd/[email protected]
fails.Curiously, installing a non-semver tag does not show this behaviour and works for both repos. Likewise, installations using "latest", a branch name or the commit digest (SHA-1) are not affected by the project structure. The following script can be used to replicate the failure:
What did you expect to see?
I expected
go install
to work with semver-tagged revisions irrespective of project structure and install the executablewise_app_subdir
in$GOPATH/bin
.What did you see instead?
The text was updated successfully, but these errors were encountered: