> ## Documentation Index
> Fetch the complete documentation index at: https://developer.upsun.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Go

> Upsun Cloud supports building and deploying applications written in Go using Go modules. They're compiled during the Build hook phase, and support both committed dependencies and download-on-demand.

> [!TIP]
>
> You can now use composable image to install runtimes and tools in your application container. To find out more, see the [Composable image](https://developer.upsun.com/docs/configure-apps/app-reference/composable-image.md) topic.

## Supported versions

You can select the major and minor version.

Patch versions are applied periodically for bug fixes and other maintenance updates. By default, you get the latest available patches each time you deploy. If your project has a [maintenance window](https://developer.upsun.com/docs/core-concepts/build-deploy.md#maintenance-window) configured, Upsun Cloud applies patches only during that window. Upsun Cloud may still apply urgent or critical fixes outside of the maintenance window.

* 1.27
* 1.26

### Specify the language

To use Go, specify `golang` as your [app's `type`](https://developer.upsun.com/docs/configure-apps/app-reference/single-runtime-image#type):


&#x20;   applications:
&#x20;     \# The app's name, which must be unique within the project.
&#x20;     \<APP\_NAME>:
&#x20;       type: 'golang:\<VERSION\_NUMBER>'
&#x20;&#x20;

For example:


&#x20;   applications:
&#x20;     \# The app's name, which must be unique within the project.
&#x20;     myapp:
&#x20;       type: 'golang:\{\{version:golang:latest}}'

## Deprecated versions

The following versions are still available in your projects,
but they're at their end of life and are no longer receiving security updates from upstream.

*No deprecated versions.*

To ensure your project remains stable in the future, switch to a [supported version](#supported-versions).

## Retired versions

The following versions have been retired and are no longer available.
If your project uses a retired version, you must update to a [supported version](#supported-versions).

* 1.25
* 1.24
* 1.23
* 1.22
* 1.21
* 1.20
* 1.19
* 1.18
* 1.17
* 1.16
* 1.15
* 1.14
* 1.13
* 1.12
* 1.11
* 1.10

## Go toolchain auto download

Even though you select a specific version of Go, starting in Go 1.21, the `go` command will automatically download and use a different toolchain version as requested by the `toolchain` directive in `go.mod`, or the `GOTOOLCHAIN` environmental variable (see [Go Toolchains](https://go.dev/doc/toolchain)).

> [!NOTE]
>
> Still, it is important to keep your chosen version of Go updated in your yaml configuration file. This will ensure that you are using the most up to date software for your projects.

## Go modules

The recommended way to handle Go dependencies on Upsun Cloud is using Go module support in Go 1.11 and later. That allows the build process to use `go build` directly without any extra steps, and you can specify an output executable file of your choice. (See the examples below.)

## Building and running the application

Assuming your `go.mod` and `go.sum` files are present in your repository, your application can be built with the command `go build`, to produce a working executable. You can then start it from the `web.commands.start` directive. Note that the start command *must* run in the foreground. If the program terminates for any reason it is automatically restarted.

The following basic `.upsun/config.yaml` file is sufficient to run most Go applications.


&#x20;   applications:
&#x20;     \# The app's name, which must be unique within the project.
&#x20;     myapp:
&#x20;       type: 'golang:\{\{version:golang:latest}}'

&#x20;       hooks:
&#x20;         build: |
&#x20;           \# Modify this line if you want to build differently or
&#x20;           \# use an alternate name for your executable.
&#x20;           go build -o bin/app

&#x20;       web:
&#x20;         upstream:
&#x20;           socket\_family: tcp
&#x20;           protocol: http

&#x20;         commands:
&#x20;           \# If you change the build output in the build hook above, update this line as well.
&#x20;           start: ./bin/app

&#x20;         locations:
&#x20;           /:
&#x20;             \# Route all requests to the Go app, unconditionally.
&#x20;             allow: false
&#x20;             passthru: true

Note that there is still an Nginx proxy server sitting in front of your application.
If desired, certain paths may be served directly by Nginx without hitting your application (for static files, primarily)
or you may route all requests to the Go application unconditionally, as in the example above.

## Accessing services

To access various [services](https://developer.upsun.com/docs/add-services) with Go, see the following examples. The individual service pages have more information on configuring each service.

You can access service credentials to connect to [managed services](https://developer.upsun.com/docs/add-services) from environment variables present in the application container.
Consult each of the individual service documentation to see how to retrieve and surface credentials into your application.

* [ClickHouse](https://developer.upsun.com/docs/add-services/clickhouse.md#usage-example)
* [Elasticsearch](https://developer.upsun.com/docs/add-services/elasticsearch.md#usage-example)
* [Gotenberg](https://developer.upsun.com/docs/add-services/gotenberg.md#usage-example)
* [Headless Chrome](https://developer.upsun.com/docs/add-services/headless-chrome.md#usage-example)
* [InfluxDB](https://developer.upsun.com/docs/add-services/influxdb.md#usage-example)
* [Kafka](https://developer.upsun.com/docs/add-services/kafka.md#usage-example)
* [MariaDB/MySQL](https://developer.upsun.com/docs/add-services/mysql#usage-example)
* [Memcached](https://developer.upsun.com/docs/add-services/memcached.md#usage-example)
* [mercure](https://developer.upsun.com/docs/add-services/mercure.md#usage-example)
* [mongodb](https://developer.upsun.com/docs/add-services/mongodb.md#usage-example)
* [Network Storage](https://developer.upsun.com/docs/add-services/network-storage.md#usage-example)
* [OpenSearch](https://developer.upsun.com/docs/add-services/opensearch.md#usage-example)
* [PostgreSQL](https://developer.upsun.com/docs/add-services/postgresql#usage-example)
* [RabbitMQ](https://developer.upsun.com/docs/add-services/rabbitmq.md#usage-example)
* [Redis](https://developer.upsun.com/docs/add-services/redis.md#usage-example)
* [Solr](https://developer.upsun.com/docs/add-services/solr.md#usage-example)
* [Valkey](https://developer.upsun.com/docs/add-services/valkey.md#usage-example)
* [Varnish](https://developer.upsun.com/docs/add-services/varnish.md#usage-example)
* [Vault KMS](https://developer.upsun.com/docs/add-services/vault.md#usage-example)
* [Chroma](https://developer.upsun.com/tutorials/self-hosted/chroma.md#3-use-the-relationship-in-your-application)
* [Qdrant](https://developer.upsun.com/tutorials/self-hosted/qdrant.md#4-use-the-relationship-in-your-application)

> [!NOTE]
>
> To deploy a Go project, create a new project from the
> [Upsun Console](https://console.upsun.com/projects/create-project)
> and select a template, or push your existing code.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.