<commit_before># Go rules for [Bazel](https://bazel.build/)

Bazel ≥0.4.4 | linux-x86_64 | ubuntu_15.10-x86_64 | darwin-x86_64
:---: | :---: | :---: | :---:
[![Build Status](https://travis-ci.org/bazelbuild/rules_go.svg?branch=master)](https://travis-ci.org/bazelbuild/rules_go) | [![Build Status](http://ci.bazel.io/buildStatus/icon?job=rules_go/BAZEL_VERSION=latest,PLATFORM_NAME=linux-x86_64)](http://ci.bazel.io/job/rules_go/BAZEL_VERSION=latest,PLATFORM_NAME=linux-x86_64) | [![Build Status](http://ci.bazel.io/buildStatus/icon?job=rules_go/BAZEL_VERSION=latest,PLATFORM_NAME=ubuntu_15.10-x86_64)](http://ci.bazel.io/job/rules_go/BAZEL_VERSION=latest,PLATFORM_NAME=ubuntu_15.10-x86_64) | [![Build Status](http://ci.bazel.io/buildStatus/icon?job=rules_go/BAZEL_VERSION=latest,PLATFORM_NAME=darwin-x86_64)](http://ci.bazel.io/job/rules_go/BAZEL_VERSION=latest,PLATFORM_NAME=darwin-x86_64)

## Announcements

* **April 12, 2017**
Release [0.4.3](https://github.com/bazelbuild/rules_go/releases/tag/0.4.3) is
now available!
* **April 7, 2017** Builds using rules_go recently broke
([#361](https://github.com/bazelbuild/rules_go/issues/361)) because of a name
change in buildifier, one of our dependencies. You can upgrade to `0.3.4`,
`0.4.2`, or `master` to get your build working again.

## Contents

* [Overview](#overview)
* [Setup](#setup)
* [Generating build files](#generating-build-files)
* [FAQ](#faq)
* [Repository rules](#repository-rules)
  * [go_repositories](#go_repositories)
  * [go_repository](#go_repository)
  * [new_go_repository](#new_go_repository)
* [Build rules](#build-rules)
  * [go_prefix](#go_prefix)
  * [go_library](#go_library)
  * [cgo_library](#cgo_library)
  * [go_binary](#go_binary)
  * [go_test](#go_test)
  * [go_proto_library](#go_proto_library)

## Overview

The rules are in the alpha stage of development. They support:

* libraries
* binaries
* tests
* vendoring
* cgo
* auto generating BUILD files via gazelle
* protocol buffers (via extension //proto:go_proto_library.bzl)

They currently do not support (in order of importance):

* cross compilation
* bazel-style auto generating BUILD (where the library name is other than
  go_default_library)
* C/C++ interoperation except cgo (swig etc.)
* race detector
* coverage
* test sharding

Note: since 0.4.x this repo requires bazel ≥ 0.4.4 to function (due to the use of
BUILD.bazel files in bazelbuild/buildifier).

## Setup

* Decide on the name of your package, eg. `github.com/joe/project`. It's
  important to choose a name that will match where others will download your
  code. This will be a prefix for import paths within your project.
* Add the following to your WORKSPACE file:

    ```bzl
    git_repository(
        name = "io_bazel_rules_go",
        remote = "https://github.com/bazelbuild/rules_go.git",
        tag = "0.4.3",
    )
    load("@io_bazel_rules_go//go:def.bzl", "go_repositories")

    go_repositories()
    ```

* If your project follows the structure that `go build` uses, you
  can [generate your `BUILD` files](#generating-build-files) with Gazelle. If
  not, read on.
* Add a `BUILD` file to the top of your project. Declare the name of your
  workspace using `go_prefix`. This is used by Bazel to translate between build
  targets and import paths.

    ```bzl
    load("@io_bazel_rules_go//go:def.bzl", "go_prefix")<commit_msg>Update README.md in preparation for 0.4.4 release (#439)<commit_after># Go rules for [Bazel](https://bazel.build/)

Bazel ≥0.4.4 | linux-x86_64 | ubuntu_15.10-x86_64 | darwin-x86_64
:---: | :---: | :---: | :---:
[![Build Status](https://travis-ci.org/bazelbuild/rules_go.svg?branch=master)](https://travis-ci.org/bazelbuild/rules_go) | [![Build Status](http://ci.bazel.io/buildStatus/icon?job=rules_go/BAZEL_VERSION=latest,PLATFORM_NAME=linux-x86_64)](http://ci.bazel.io/job/rules_go/BAZEL_VERSION=latest,PLATFORM_NAME=linux-x86_64) | [![Build Status](http://ci.bazel.io/buildStatus/icon?job=rules_go/BAZEL_VERSION=latest,PLATFORM_NAME=ubuntu_15.10-x86_64)](http://ci.bazel.io/job/rules_go/BAZEL_VERSION=latest,PLATFORM_NAME=ubuntu_15.10-x86_64) | [![Build Status](http://ci.bazel.io/buildStatus/icon?job=rules_go/BAZEL_VERSION=latest,PLATFORM_NAME=darwin-x86_64)](http://ci.bazel.io/job/rules_go/BAZEL_VERSION=latest,PLATFORM_NAME=darwin-x86_64)

## Announcements

* **May 5, 2017**
Release [0.4.4](https://github.com/bazelbuild/rules_go/releases/tag/0.4.4) is
now available!
* **April 12, 2017**
Release [0.4.3](https://github.com/bazelbuild/rules_go/releases/tag/0.4.3) is
now available!
* **April 7, 2017** Builds using rules_go recently broke
([#361](https://github.com/bazelbuild/rules_go/issues/361)) because of a name
change in buildifier, one of our dependencies. You can upgrade to `0.3.4`,
`0.4.2`, or `master` to get your build working again.

## Contents

* [Overview](#overview)
* [Setup](#setup)
* [Generating build files](#generating-build-files)
* [FAQ](#faq)
* [Repository rules](#repository-rules)
  * [go_repositories](#go_repositories)
  * [go_repository](#go_repository)
  * [new_go_repository](#new_go_repository)
* [Build rules](#build-rules)
  * [go_prefix](#go_prefix)
  * [go_library](#go_library)
  * [cgo_library](#cgo_library)
  * [go_binary](#go_binary)
  * [go_test](#go_test)
  * [go_proto_library](#go_proto_library)

## Overview

The rules are in the alpha stage of development. They support:

* libraries
* binaries
* tests
* vendoring
* cgo
* auto generating BUILD files via gazelle
* protocol buffers (via extension //proto:go_proto_library.bzl)

They currently do not support (in order of importance):

* cross compilation
* bazel-style auto generating BUILD (where the library name is other than
  go_default_library)
* C/C++ interoperation except cgo (swig etc.)
* race detector
* coverage
* test sharding

Note: since 0.4.x this repo requires bazel ≥ 0.4.4 to function (due to the use of
BUILD.bazel files in bazelbuild/buildifier).

## Setup

* Decide on the name of your package, eg. `github.com/joe/project`. It's
  important to choose a name that will match where others will download your
  code. This will be a prefix for import paths within your project.
* Add the following to your WORKSPACE file:

    ```bzl
    git_repository(
        name = "io_bazel_rules_go",
        remote = "https://github.com/bazelbuild/rules_go.git",
        tag = "0.4.4",
    )
    load("@io_bazel_rules_go//go:def.bzl", "go_repositories")

    go_repositories()
    ```

* If your project follows the structure that `go build` uses, you
  can [generate your `BUILD` files](#generating-build-files) with Gazelle. If
  not, read on.
* Add a `BUILD` file to the top of your project. Declare the name of your
  workspace using `go_prefix`. This is used by Bazel to translate between build
  targets and import paths.

    ```bzl
    load("@io_bazel_rules_go//go:def.bzl", "go_prefix")
{'fraction_non_alphanumeric': 0.14531158998252766, 'fraction_numerical': 0.02810133954571928, 'mean_word_length': 4.676859504132231, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 13, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5051863', 'n_tokens_mistral': 2655, 'n_tokens_neox': 2431, 'n_words': 560}