Skip to content

Helper CLI for adding third party go dependencies to a Please.build enabled repo

Notifications You must be signed in to change notification settings

jamesjarvis/go-deps

Repository files navigation

Go-Deps

The goal of this project is to build a migration tool to convert a Please based repo using deprecated go_get rules to use the now standard go_module rules.

The difference between please and bazel is that please requires the user to specify the module dependencies, which can be a little bit annoying.

Rough idea

The rough idea of this project is to have two modes:

  1. Please just add this module to the project
    • Basically just run a binary, passing in the specified module + version + optionally the name for it
    • This will then parse the existing build files to check if it already exists, and then add this module + it's dependencies to the repo.
    • The idea is that in order to find out the dependencies of a particular module, it will run go get (or go mod download idk) and then cd into the cache directory and run go list -m -json all on that stuff, to work out what the dependencies are.
  2. Please just convert the existing go_get definitions into go_modules (should theoretically just call the above mentioned binary).

Current Progress

Currently, we are at step 1.5, ie: we can pass in a module + optionally version and it will resolve the dependencies for it and it's dependencies:

itis@whatitis go-deps % go run cmd/main.go -m github.com/hashicorp/go-hclog
Please Go Get v0.0.1
So, you want to add "github.com/hashicorp/go-hclog"?
Congrats, you just downloaded "github.com/hashicorp/[email protected]"
2021/08/04 23:22:56 Dependencies change! We started with github.com/mattn/[email protected] and now have github.com/mattn/[email protected]
2021/08/04 23:22:57 Dependencies change! We started with golang.org/x/[email protected] and now have golang.org/x/[email protected]
2021/08/04 23:22:57 Synced github.com/mattn/[email protected] --> github.com/mattn/[email protected]
MODULE: github.com/hashicorp/go-hclog
 VERSION: v0.16.2
  github.com/hashicorp/[email protected]
  |
  |---- github.com/fatih/[email protected]
  |---- github.com/mattn/[email protected]
  |---- github.com/mattn/[email protected]
  |---- github.com/stretchr/[email protected]
MODULE: github.com/fatih/color
 VERSION: v1.7.0
  github.com/fatih/[email protected]
MODULE: github.com/mattn/go-colorable
 VERSION: v0.1.4
  github.com/mattn/[email protected]
  |
  |---- github.com/mattn/[email protected]
MODULE: github.com/mattn/go-isatty
 VERSION: v0.0.10
  github.com/mattn/[email protected]
  |
  |---- golang.org/x/[email protected]
MODULE: github.com/stretchr/testify
 VERSION: v1.2.2
  github.com/stretchr/[email protected]
MODULE: golang.org/x/sys
 VERSION: v0.0.0-20191008105621-543471e840be
  golang.org/x/[email protected]

About

Helper CLI for adding third party go dependencies to a Please.build enabled repo

Topics

Resources

Stars

Watchers

Forks