> For the complete documentation index, see [llms.txt](https://shapeshiftdao.gitbook.io/unchained/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://shapeshiftdao.gitbook.io/unchained/go.md).

# Go

## Project Structure

* `pkg` - shared common packages across coinstacks
* `internal` - internal utility packages
* `coinstacks/{coin}` - coin specific logic

## Dependencies

* [go](https://go.dev/)
* [goimports](https://pkg.go.dev/golang.org/x/tools/cmd/goimports)
* [golangci-lint](https://golangci-lint.run/)

## Notes

* It is suggested configuring your editor of choice to utilize the following tooling:
  * [gopls](https://pkg.go.dev/golang.org/x/tools/gopls) language server
  * [golangci-lint](https://golangci-lint.run/) to match the linter used in CI
  * [goimports](https://pkg.go.dev/golang.org/x/tools/cmd/goimports) to match the formatting run on git pre-commit hook (default behavior when using gopls)
* Visual Studio Code expects any golang projects to be opened up with a `go.mod` file at the root directory for the tooling to work properly, so be sure to open up the project at `unchained/go`

## Initial Setup

* Install [Golang](https://go.dev/doc/install)

  make sure `GOPATH` is set in your shell environment, since it's needed for `docker-compose` setup to work properly
* Make coinstacks

  ```sh
  cd go && make
  ```
* Copy sample env file:

  ```sh
  cp go/cmd/ethereum/sample.env go/cmd/ethereum/.env
  ```
* Go to `unchained/` and install dependencies by running `yarn` (which will also prepare the git pre-commit hook with `goimports`)

  ```sh
  yarn
  ```
