Dependencies

GOX manages the project's direct dependencies by gox.json and keeps synchronized deps.go, go.mod and go.sum with Go's tools.

The commands get, remove, install and tidy are part of the same administration flow. To consult the installed dependencies, use gox list.


Commands

CommandDescription
getAdd or update a dependency.
removeIt eliminates a dependency.
installInstall and reconcile the declared dependencies.
tidySynchronize the Go modules.
listIt shows the project dependencies.

get

bash
gox get <package>[@version]

get add the package to gox.json and immediately runs the installation of dependencies.

bash
gox get github.com/redis/go-redis/v9
gox get example.com/[email protected]

If the version is omitted, GOX stores latest. The separation between the package and the version uses the last character @ of the argument.

The command requires exactly a package.

If the installation fails, GOX restores the previous status of the managed files and the dependency is not partially added.


remove

bash
gox remove <package>

remove removes the package from gox.json and resynchronize the dependencies:

bash
gox remove github.com/redis/go-redis/v9

The GOX's main SDK is a protected dependency and cannot be removed by this command.

The command requires exactly one package. If the synchronization fails, GOX restores the previous state of the managed files.


install

bash
gox install

install Read gox.json, reconciles the declared versions and synchronizes the Go modules.

During the operation, GOX:

  1. It guarantees the availability of the Go toolchain.
  2. Synchronize the permanent bridge deps.go with the dependencies declared.
  3. Install the dependencies in stable order.
  4. Executed go mod tidy by the toolchain administered.
  5. It guarantees the availability of Node.js and PNPM.

The command does not accept arguments. The preparation of Node.js and PNPM does not install or reconstruct by itself the workspaces of frameworks; that operation belongs to gox client add.


tidy

bash
gox tidy

tidy synchronized deps.go, go.mod and go.sum with dependencies declared unmodified gox.json.

So that the Go tools can observe the imports used only by files .gox, GOX keeps deps.go updated before running go mod tidy by your toolchain administered.


gox.json

Direct dependencies are stored as a package and version map:

json
{
  "dependencies": {
    "github.com/redis/go-redis/v9": "latest"
  }
}

The modules can then be imported from GOX using the imports.


deps.go

deps.go is a file generated and maintained by GOX at the root of the project. Its function is to make visible for the tools of go modules the dependencies that can be used only from files .gox.

GOX synchronizes this file during dependency operations. If there is already a deps.go which does not belong to GOX, the operation fails instead of overwriting it.

deps.go is part of the administered state of the project and is not eliminated after install or tidy.


Errors and consistency

An invalid dependency, a gox.json misformed or an error of the Go tools interrupt the command.

get and remove apply their changes transactional. If the subsequent installation or synchronization fails, GOX restores the previous state of gox.json, deps.go, go.mod and go.sumincluding the prior absence of any of these files.


Best practices

  • It uses explicit versions for reproducible building.
  • Preservation gox.json, deps.go, go.mod and go.sum under version control.
  • Do not manually edit the deps.go administered by GOX.
  • Executed gox install after getting dependency changes.
  • Use gox list to consult the direct dependencies declared and gox list -t when you need the effective module graph.

See also

Next step

Continue with list to consult the direct and transitive dependencies of the project.

list