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

x/tools/gopls: Does GOPACKAGESDRIVER support custom packages ? #69501

Closed
ViolaPioggia opened this issue Sep 17, 2024 · 10 comments
Closed

x/tools/gopls: Does GOPACKAGESDRIVER support custom packages ? #69501

ViolaPioggia opened this issue Sep 17, 2024 · 10 comments
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@ViolaPioggia
Copy link

gopls version

gopls -v version
Build info

golang.org/x/tools/gopls v0.16.1
golang.org/x/tools/[email protected] h1:1hO/dCeUvjEYx3V0rVvCtOkwnpEpqS29paE+Jw4dcAc=
github.com/BurntSushi/[email protected] h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
github.com/google/[email protected] h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
golang.org/x/exp/[email protected] h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
golang.org/x/[email protected] h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
golang.org/x/[email protected] h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/[email protected] h1:3Wt8mZlbFwG8llny+t18kh7AXxyWePFycXMuVdHxnyM=
golang.org/x/[email protected] h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/[email protected] h1:Kd+Z5Pm6uwYx3T2KEkeHMHUMZxDPb/q6b1m+zEcy62c=
golang.org/x/[email protected] h1:SP0mPeg2PmGCu03V+61EcQiOjmpri2XijexKdzv8Z1I=
honnef.co/go/[email protected] h1:9MDAWxMoSnB6QoSqiVr7P5mtkT9pOc1kSxchzPCnqJs=
mvdan.cc/[email protected] h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo=
mvdan.cc/xurls/[email protected] h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: go1.22.6

go env

go env
GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/violapioggia/Library/Caches/go-build'
GOENV='/Users/violapioggia/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/violapioggia/go/pkg/mod'
GONOPROXY='talkcheap.xiaoeknow.com'
GONOSUMDB='talkcheap.xiaoeknow.com'
GOOS='darwin'
GOPATH='/Users/violapioggia/go'
GOPRIVATE='talkcheap.xiaoeknow.com'
GOPROXY='https://goproxy.cn,direct'
GOROOT='/usr/local/go'
GOSUMDB='off'
GOTMPDIR=''
GOTOOLCHAIN=''
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.1'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/violapioggia/GolandProjects/rgo/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/2y/q5hfz55n7yx__bgtrj0pwgpw0000gn/T/go-build2651212672=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

I use GOPACKAGESDRIVER to build a custom package which name's github.com/xxx/xxx

What did you see happen?

when I execute go mod tidy ,it will throw an error:

(base) ViolaPioggiadeMacBook-Air:rgo_test violapioggia$ go mod tidy
go: finding module for package github.com/xxx
go: test imports
github.com/xxx: cannot find module providing package github.com/xxx: module github.com/xxx: git ls-remote -q origin in /Users/violapioggia/go/pkg/mod/cache/vcs/6d9364d47d76a0951f605c504e9f49ac68af057ddde3e30b0f18dcf04c652806: exit status 128:
remote: Repository not found.
fatal: repository 'https://github.com/xxx: not found

What did you expect to see?

I want I can import custom_pacakge github.com/xxx by GOPACKAGESDRIVER like normal package and execute go mod tidy won't throw an error

Editor and settings

{
"go.toolsEnvVars": {
"GOPACKAGESDRIVER": "${env:GOPATH}/bin/mypackagesdriver"
},
}

Logs

No response

@ViolaPioggia ViolaPioggia added gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels Sep 17, 2024
@gopherbot gopherbot added this to the Unreleased milestone Sep 17, 2024
@li-jin-gou
Copy link

Hello @findleyr , can you help us look into this issue? I'm not sure if this capability is supported now.

@adonovan
Copy link
Member

As far as I can tell, you want the go command to somehow use a custom GOPACKAGESDRIVER, but the go command knows nothing of this concept: it is part of https://pkg.go.dev/golang.org/x/tools/go/packages, which is a library for loading Go project metadata by running build tools like go list, or alternatives such as like bazel, buck, and pants. And I don't see how this relates at all to gopls.

Could you explain the problem in more detail?

@li-jin-gou
Copy link

Sorry @adonovan ,it may have mentioned the wrong issue category.

We use GOPACKAGESDRIVER in the hope of injecting three-way packages, in the form of github.com/hertz_gen/a, but using go mod tidy will go and pull the packages remotely, resulting in a package does not exist error.

I'm currently wondering if GOPACKAGESDRIVER supports emulating three-way packages and go mod tidy doesn't report an error?

We can resubmit an issue to the correct category.

@adonovan
Copy link
Member

We use GOPACKAGESDRIVER in the hope of injecting three-way packages, in the form of github.com/hertz_gen/a, but using go mod tidy will go and pull the packages remotely, resulting in a package does not exist error.
I'm currently wondering if GOPACKAGESDRIVER supports emulating three-way packages and go mod tidy doesn't report an error?

I have not heard the term "three-way package" before. What does it mean?

@li-jin-gou
Copy link

We use GOPACKAGESDRIVER in the hope of injecting three-way packages, in the form of github.com/hertz_gen/a, but using go mod tidy will go and pull the packages remotely, resulting in a package does not exist error.
I'm currently wondering if GOPACKAGESDRIVER supports emulating three-way packages and go mod tidy doesn't report an error?

I have not heard the term "three-way package" before. What does it mean?

sry,it is Third-Party Packages😞 such as github.com/protoc_gen/service package

@ViolaPioggia
Copy link
Author

ViolaPioggia commented Sep 20, 2024

sry,it is Third-Party Packages😞 such as github.com/protoc_gen/service package

It is exactly what I mean, when I using gopackgesdriver to build a pacakge like this, go mod tidy will try to download from github.com but not load from my local env

@adonovan
Copy link
Member

adonovan commented Sep 20, 2024

GOPACKAGESDRIVER is for when you are using a build system other than the Go command. In general, other build systems are not compatible (or fully compatible) with the Go command's module system--some don't really use modules at all--so go mod tidy will not work as expected.

What build system are you using? What program is GOPACKAGESDRIVER set to? Neither of the two GitHub repos you mentioned (github.com/protoc_gen/service and github.com/hertz_gen/a) are readable to me. Do they require authentication? Are you trying to use GOPACKAGESDRIVER as some kind of authentication proxy?

@ViolaPioggia
Copy link
Author

GOPACKAGESDRIVER is for when you are using a build system other than the Go command. In general, other build systems are not compatible (or fully compatible) with the Go command's module system--some don't really use modules at all--so go mod tidy will not work as expected.

What build system are you using? What program is GOPACKAGESDRIVER set to? Neither of the two GitHub repos you mentioned (github.com/protoc_gen/service and github.com/hertz_gen/a) are readable to me. Do they require authentication? Are you trying to use GOPACKAGESDRIVER as some kind of authentication proxy?

Thanks for replying, I dont't want to use GOPACKAGESDRIVER as some kind of authentication proxy, I just want to use GOPACKAGESDRIVER to build a package which prefix is "github.com/xxx" and when I execute 'go mod tidy',because of this package is not managed by go module ,so it will throw an error like below picture

image

@hyangah
Copy link
Contributor

hyangah commented Oct 3, 2024

Thanks for replying, I dont't want to use GOPACKAGESDRIVER as some kind of authentication proxy, I just want to use GOPACKAGESDRIVER to build a package which prefix is "github.com/xxx" and when I execute 'go mod tidy',because of this package is not managed by go module ,so it will throw an error like below picture

It's unclear exactly what you are trying to achieve - go command does not understand GOPACKAGESDRIVER because GOPACKAGESDRIVER is for the case where go command shouldn't be used. It looks like you still want to use the go command e.g. go mod tidy. That cannot work.

If your issue is about working with private or unpublished modules and you still use the go command, depending on the situation, you can consider the followings:

I hope one of the above can help you achieve what you want.

For further questions, please use the channels listed in https://go.dev/wiki/Questions

Closing since it is not a gopls issue nor GOPACKAGESDRIVER issue.

@hyangah hyangah closed this as completed Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

6 participants