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

Updating tutorial to spike deps.bzl file #74

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion go-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Copy link
Contributor

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"

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
Copy link
Contributor

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The 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`
Expand Down