go vendor_path doesn't work
See original GitHub issueThe doc of vendor_path says “Packages in these directories are allowed to be imported given just the relative path to the package”. However, when I tried to import a third-party package in the vendor/
directory configured by vendor_path
, buck couldn’t import the package.
This is my .buckconfig
file:
[go]
vendor_path = ./vendor
This is my BUCK
file:
go_test(
name='command_test',
srcs=['command_test.go']
)
This is the command_test.go
file:
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestName(t *testing.T) {
assert.Equal(t, "name", "name")
}
When I ran buck test //:command_test
, buck said:
command_test.go:6:2: can't find import: "github.com/stretchr/testify/assert"
However, the package exists in vendor/github.com/stretchr/testify/assert/
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
golang vendor path cannot find package - Stack Overflow
The solution: Move the current working directory into GOPATH/src/ and the problem is solved. Not only the ./vendor can be used, but also...
Read more >go/build: vendor directories are ignored when outside ... - GitHub
The project gets clone on the build machine in /build/project, which is not inside the go path. The build fails due to import...
Read more >Go 1.5 Vendor Experiment - Google Git
The short form must always be used: no import path can contain “/vendor/” explicitly. Import comments are ignored in vendored packages. The interpretation...
Read more >Go | IntelliJ IDEA Documentation - JetBrains
Working with Go modules. In the Project tool window (View | Tool Windows | Project), Go modules are displayed with their full import...
Read more >Vendoring + submodules: go get error - Google Groups
I am trying to get vendoring working with submodules. While the building part works fine the "go get" ... `go get` doesn't operate...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Now I see the reason. I have
package_name='github.com/stretchr/testify/assert'
in the BUCK file. So it overrides thevendor_path
. Thanks for the help!If you turn on verbose output you can see exactly what Buck is doing.
Specifically the compile command has imports mapped.
Since it’s still hard to see
-importmap 'github.com/pkg/errors=third-party/go/github.com/pkg/errors'
which does the mapping to make the compiler happy. It’s not a really big feature but useful for us.