# Installation
cff is a library and a CLI.
You can install these independently with go get
/go install
(see Manual setup)
but we recommend using the following instructions
to set up your project to use it.
# Recommended setup
# One-time setup
Prerequisites
- Go 1.18 or newer
- a project with a go.mod file
Most Go projects should take the following steps to set up cff.
Inside the project directory, create a 'tools.go' if one doesn't already exist. This is where you'll specify development-time dependencies.
cat > tools.go <<EOF //go:build tools package tools // use your project's package name here EOF
Make sure you use the same package name as your project directory.
Add
import _ "go.uber.org/cff/cmd/cff"
to the tools.go.echo 'import _ "go.uber.org/cff/cmd/cff"' >> tools.go
Run
go mod tidy
to pick up the latest version of cff, or rungo get go.uber.org/cff@main
to get the current unreleased branch.go mod tidy
Install the cff CLI to a bin/ subdirectory of the project.
GOBIN=$(pwd)/bin go install go.uber.org/cff/cmd/cff
Feel free to gitignore this directory.
echo '/bin' >> .gitignore
Add the following
go:generate
directive to an existing Go file in the same directory.//go:generate bin/cff ./...
# Setup on new machines
Once a project is already using cff, new machines that work on the project simply need to install the cff CLI into the bin/ directory.
GOBIN=$(pwd)/bin go install go.uber.org/cff/cmd/cff
We recommend incorporating this into your project setup instructions or scripts.
# Manual setup
Alternatively, you can install the cff CLI and library independently:
Add the library as a dependency of the project.
go get go.uber.org/cff
Install the CLI globally.
go install go.uber.org/cff/cmd/cff