Go modules for non go repository

651 views
Skip to first unread message

ever...@gmail.com

unread,
Dec 20, 2019, 1:42:55 AM12/20/19
to golang-nuts
Hello- I have a go project with a list of dependencies that are tools. They aren't directly included by any .go files in the repos, so instead I have a file called "tools.go" with a build constraints. One dependency "tools-project" doesn't have any golang code:


// +build tools

package tools

import (
   
github.com/some-team/tools-project
)




 This works to make go modules happy, but `go mod tidy` and `go mod why` fail with an error like this: 

github.com/my-team/my-project/pkg imports
 github
.com/some-team/tools-project: module github.com/some-team/tools-project@latest found (vX.X.X), but does not contain package github.com/some-team/tools-project

This might be because there's no golang code in that tool repo? I was wondering if there's a better way to specify and keep a versioned lock on a non golang repo.

Thanks.

ever...@gmail.com

unread,
Dec 20, 2019, 12:45:42 PM12/20/19
to golang-nuts
To clarify, the `// +build tools` should make the compiler skip building this file because the "tools" constraint will never be met, but allows go modules to add it to the dependency list. It just looks like go mod tidy doesn't like non go repositories.

cjam...@tableau.com

unread,
May 29, 2020, 12:27:25 PM5/29/20
to golang-nuts
I'm interested in this idea for a similar situation we're in.

- What version of Go were you using?
- Has you strategy been working reasonably well for the past 5+ months?
- When does `go mod tidy` or `go mod why` come up for you, and is it a significant blocker?

Thanks!
C.J. Jameson

ever...@gmail.com

unread,
May 30, 2020, 12:02:54 PM5/30/20
to golang-nuts
This solution has been working well and we still use it. The go mod & tidy tools not working hasn't really been an issue. 

ever...@gmail.com

unread,
May 30, 2020, 12:06:09 PM5/30/20
to golang-nuts
go mod why* & tidy
Reply all
Reply to author
Forward
0 new messages