-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Updating tutorial to spike deps.bzl file #74
Open
chrislovecnm
wants to merge
1
commit into
bazel-contrib:gh-pages
Choose a base branch
from
lionkube:go-updates
base: gh-pages
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -248,7 +248,6 @@ Use your favorite editor and create a file named `WORKSPACE` in the root directo | |
|
||
Edit the `WORKSPACE` file and include the following Starlark code. | ||
|
||
|
||
```python | ||
# use http_archive to download bazel rules_go | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
@@ -306,6 +305,29 @@ to the version you would like to use of Go. | |
|
||
Next, we need a `BUILD.bazel` file in the root project directory. | ||
|
||
## Create the intial `deps.bzl` file | ||
|
||
In order for gazelle to run properly the first time, you may need to create a `deps.bzl` file in the root directory of | ||
your project. Here is an example of the `deps.bzl` file: | ||
|
||
```python | ||
def go_dependencies(): | ||
pass | ||
``` | ||
|
||
The above Starlark code defines the function that is reference in the `WORKSPACE` file. Below is a snippet | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is reference -> is referenced |
||
of the `WORKSPACE` file: | ||
|
||
```python | ||
# gazelle:repository_macro deps.bzl%go_dependencies | ||
go_dependencies() | ||
``` | ||
|
||
Once you run gazelle for the first time, if you have any external Go dependencies, gazelle will update the | ||
`deps.bzl` file to include definitions of the external dependencies. The `deps.bzl` is not required but allows | ||
gazelle to store the projects external Go dependencies in a seperate file. Otherwise all of the external Go dependencies | ||
are defined in the `WORKSPACE` file, and if you have a large project, you can have hundreds of extra | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sentence is dangling |
||
|
||
## Create the initial `BUILD.bazel` file | ||
|
||
Open your editor and create a file named `BUILD.bazel`. Write the following contents to the `BUILD.bazel` | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not "to run properly" right? If you go with the default behavior then the deps go in WORKSPACE like you say later. So it's more about "if you want to keep your WORKSPACE shorter"