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

Add support for short import paths for packages in the same module #41568

Closed
alexus1024 opened this issue Sep 23, 2020 · 2 comments
Closed

Add support for short import paths for packages in the same module #41568

alexus1024 opened this issue Sep 23, 2020 · 2 comments

Comments

@alexus1024
Copy link

@alexus1024 alexus1024 commented Sep 23, 2020

What version of Go are you using (go version)?

go version go1.15 darwin/amd64

Does this issue reproduce with the latest release?

This is proposal. So, yes.

What operating system and processor architecture are you using (go env)?

go env Output
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users//Library/Caches/go-build"
GOENV="/Users//Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users//go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users//go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.15/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.15/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/nx/_fxcwls90392z82dwl07768r0000gn/T/go-build100053484=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

  1. make a go module
    go.mod
module gitlab.my-work.int/some-long-path/some-project-name/some-project-part

go 1.15

  1. add go files to module. Add internal imports to each other. Use some short notation for internal references.
    ./tools/plus.go
package tools
func Plus(a,b int) int { return a+b }

./one.go

package main

// import gitlab.my-work.int/some-long-path/some-project-name/some-project-part/tools. // currently working scenario
import LOCAL/tools. // works according this proposal. "LOCAL" - is an example label for current module
  
func main(){
   fmt.Println(tools.Plus(1,2))
}

What did you expect to see?

LOCAL imports works.

What did you see instead?

LOCAL/tools not found.
go build/get even try to download it.

Some motivation details

Clones

Can't make go-gettable fork of golang module without changing every file in it.
In order to make fork to be a valid module you should change it's module name according repo name. And all imports in all files as consequence.
Of course, there will be troubles in sync process later.

IDE

Currently on any typo in internal imports, "go get" will try to download internal package. And error will not be "hey, there is typo in your import", but "some server returned 404" or even "invalid credentials" for non-public repos.

Import ordering

Clear way to order internal imports into separate block. Currently its a complex task for code analyze systems.

Just shorter and more clear

Yes, just shorter and more clear

@bcmills
Copy link
Member

@bcmills bcmills commented Sep 23, 2020

@bcmills
Copy link
Member

@bcmills bcmills commented Sep 23, 2020

Duplicate of #26645

@bcmills bcmills marked this as a duplicate of #26645 Sep 23, 2020
@bcmills bcmills closed this Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.