# jf go Run Go commands with Artifactory integration, including configuration, builds, and publishing. This topic covers the following tasks: * [Configure Go for Artifactory (`jf go-config`)](#configuration-jf-go-config) * [Run Go commands (`jf go`)](#build-jf-go) * [Publish Go modules (`jf go-publish`)](#publish-jf-go-publish) ## When to Use Use `jf go` if your Go project uses Go modules (`go.mod`) and you want dependencies resolved from Artifactory. The CLI wraps `go build`, `go get`, and other Go commands while setting `GOPROXY` to point at your Artifactory Go repository. ## Prerequisites * Go must be installed (Go 1.16+ recommended for module support). * Run `jf go-config` in the project directory before the first build. * Configure a server with `jf config add` or `jf c add`. * Authentication to Artifactory is required. *** ## Configuration: `jf go-config` Generate Go build configuration for dependency resolution and deployment. **Run this once per project before your first build.** **To configure Go for Artifactory:** ### Synopsis ``` jf go-config [options] ``` **Aliases:** `goc` ### Configuration Options | Flag | Default | Description | | --------------------- | ------- | ------------------------------------------------------------------------------------ | | `--global` | `false` | Set to true for global configuration (all projects). Specific projects can override. | | `--repo-deploy` | — | Repository for artifacts deployment | | `--repo-resolve` | — | Repository for dependencies resolution | | `--server-id-deploy` | — | Artifactory server ID for deployment. Configure with `jf config add`. | | `--server-id-resolve` | — | Artifactory server ID for resolution. Configure with `jf config add`. | ### Configuration Examples #### View Help ```bash jf go-config --help ``` #### Non-Interactive Configuration with Flags ```bash jf go-config --server-id-resolve= --repo-resolve= --server-id-deploy= --repo-deploy= ``` Where: * \: The server ID configured using `jf config add` * \: The name of the repository in Artifactory For example: ```bash jf go-config --server-id-resolve=my-server --repo-resolve=go-virtual --server-id-deploy=my-server --repo-deploy=go-local ``` ### Why Run Config First? You must run `jf go-config` **before** `jf go` or `jf go-publish`. The config tells the CLI which Artifactory Go repositories to use, setting `GOPROXY` automatically during builds. Without it, `jf go` does not know where to fetch or publish modules. > **Shortcut**: In CI/CD, pass all flags non-interactively so the config step is fully automated and reproducible. ### Configuration Notes * **Run once per project**: Configuration persists in `.jfrog/projects/go.yaml`. * **Resolution and deployment**: Use `--repo-resolve` for fetching modules and `--repo-deploy` for publishing. * **GOPROXY override**: The CLI temporarily sets `GOPROXY` during execution, overriding any system setting. ### Expected Output ``` $ jf go-config --server-id-resolve=my-server --repo-resolve=go-virtual --server-id-deploy=my-server --repo-deploy=go-local Go build configuration saved successfully. ``` ### How to Verify After running, confirm the configuration exists: ```bash cat .jfrog/projects/go.yaml ``` *** ## Build: `jf go` Run Go commands with Artifactory integration and optional build-info collection. **To run Go commands with Artifactory integration:** ### Synopsis ``` jf go [options] ``` **Aliases:** none ### Arguments | Argument | Required | Description | | ---------------- | -------- | ----------------------------------------------------------------------------- | | `` | Yes | Arguments and options for the Go command (for example, `build`, `get`, `mod`) | ### Build Options | Flag | Default | Description | | ---------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | `--build-name` | — | Build name for build-info. Requires `--build-number`. | | `--build-number` | — | Build number for build-info. Requires `--build-name`. | | `--module` | — | Optional module name for build-info. Requires `--build-name` and `--build-number`. | | `--no-fallback` | `true` | When `true` (the default), packages missing in Artifactory will not be downloaded from VCS. Set to `false` to allow fallback to direct VCS download. | | `--project` | — | JFrog Artifactory project key | ### Build Examples #### Run Go Build ```bash jf go --help ``` #### Run Go with Build-Info Collection ```bash jf go build --build-name= --build-number= ``` Where: * `` is a name for the build (e.g., `my-go-app`) * `` is a number or identifier for the build run (e.g., `1`) For example: ```bash jf go build --build-name=my-go-app --build-number=1 ``` #### Run Go Get with No VCS Fallback ```bash jf go get --no-fallback ``` Where: * `` is the Go module path (e.g., `github.com/example/lib`) For example: ```bash jf go get github.com/example/lib --no-fallback ``` *** ## Publish: `jf go-publish` Publish a Go package and its dependencies to Artifactory. **To publish a Go package to Artifactory:** ### Synopsis ``` jf go-publish [options] ``` **Aliases:** `gp` ### Arguments | Argument | Required | Description | | ------------------- | -------- | -------------------------------------------------- | | `` | Yes | Package version to publish (for example, `v1.0.0`) | ### Publish Options | Flag | Default | Description | | -------------------- | ------- | ---------------------------------------------------------------------------------- | | `--build-name` | — | Build name for build-info. Requires `--build-number`. | | `--build-number` | — | Build number for build-info. Requires `--build-name`. | | `--detailed-summary` | `false` | Set to true to include a list of affected files in the summary | | `--exclusions` | — | Semicolon-separated exclusions. Supports `*` and `?` wildcards. | | `--module` | — | Optional module name for build-info. Requires `--build-name` and `--build-number`. | | `--project` | — | JFrog Artifactory project key | | `--url` | — | JFrog platform URL | | `--user` | — | JFrog username | | `--password` | — | JFrog password | | `--access-token` | — | JFrog access token | ### Publish Examples #### View Help ```bash jf go-publish --help ``` #### Publish a Package Version ```bash jf go-publish v1.0.0 ``` #### Publish with Build-Info and Detailed Summary ```bash jf go-publish v1.0.0 --build-name=my-app --build-number=1 --detailed-summary ``` #### Publish with Exclusions ```bash jf go-publish v1.0.0 --exclusions="test/*;*.md" ``` *** ## Important Notes * **VCS fallback**: By default, `--no-fallback` is `true`, meaning the CLI will **not** fall back to the public VCS (for example, GitHub) if a module is missing in Artifactory. To allow VCS fallback, pass `--no-fallback=false`. * **GOPROXY**: The CLI sets `GOPROXY` to point at your Artifactory Go repository. This overrides any existing `GOPROXY` setting for the duration of the command. * **Build-info**: Use `--build-name` and `--build-number` to collect dependency information, then publish with `jf rt build-publish`. * **Version format**: The version must follow Go module versioning (for example, `v1.0.0`, `v2.1.3`). The `v` prefix is required. * **Exclusions**: Use `--exclusions` to exclude test files, documentation, or other files you don't want in the published module. ## Platform Notes * **Windows:** Go module archive creation may behave differently with path separators. Use forward slashes in exclusion patterns. * **macOS / Linux:** `GOPROXY` environment variable is temporarily overridden during `jf go` execution. Check with `go env GOPROXY` after the command completes to verify it was restored. ## CI/CD Example (GitHub Actions) ```yaml # .github/workflows/build.yml steps: - uses: actions/checkout@v4 - name: Setup JFrog CLI uses: jfrog/setup-jfrog-cli@v4 env: JF_URL: ${{ vars.JF_URL }} JF_ACCESS_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }} - name: Configure Go run: jf go-config --server-id-resolve=setup-jfrog-cli-server --repo-resolve=go-virtual --server-id-deploy=setup-jfrog-cli-server --repo-deploy=go-local - name: Build run: jf go build --build-name=my-go-app --build-number=${{ github.run_number }} --no-fallback - name: Publish module run: jf go-publish v1.0.0 --build-name=my-go-app --build-number=${{ github.run_number }} - name: Publish build info run: jf rt build-publish my-go-app ${{ github.run_number }} ``` ## Troubleshooting | Symptom | Cause | Fix | | -------------------------------------- | --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | | `no config file was found` | `jf go-config` was not run | Run `jf go-config` in the project directory | | 404 on `jf go build` | Resolution repository does not exist or module not cached | Verify `--repo-resolve` matches an existing Go virtual repository; set `--no-fallback=false` to allow VCS fallback | | 401 / 403 errors | Invalid credentials or insufficient permissions | Re-run `jf config add` with a valid access token | | Module version rejected by Artifactory | Version does not follow `vX.Y.Z` format | Ensure the version starts with `v` (for example, `v1.0.0`) | | `GOPROXY` conflicts | Existing `GOPROXY` overridden during CLI execution | The CLI sets `GOPROXY` temporarily; this is expected behavior | | `jf go-publish` uploads unwanted files | Test or doc files included | Use `--exclusions="test/*;*.md"` to exclude them | **Enable debug logging:** `export JFROG_CLI_LOG_LEVEL=DEBUG`
## Related Topics * [Build Tools Overview](/artifactory/docs/build-tool-commands) — Capabilities matrix and tool reference * [Native Mode](/artifactory/docs/native-mode) — Supported packages with Native Mode