{
  "id": 22655285,
  "title": "What a Go App Needs Before You Deploy It (with a ShardCloud Walkthrough)",
  "url": "https://urgent.news/2026/11/29/what-a-go-app-needs-before-you-deploy-it-with-a-shardcloud-walkthrough",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-29T20:33:09.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/shardcloud/what-a-go-app-needs-before-you-deploy-it-with-a-shardcloud-walkthrough-5cb6"
  },
  "original_language": null,
  "account": "Deploying a Go application requires careful consideration of several factors before going live. A Go application that runs locally on your laptop may encounter different issues when deployed to a hosting platform. Two common problems are the platform failing to start the app or the proxy not receiving a response from it. To differentiate between these issues, we'll deploy a small API using Go's standard library and analyze the build and startup logs.\n\nIn Go, a package build and a file build can include different code. The `go run .` command executes the package in the current directory, allowing it to pick up both `main.go` and `handlers.go`. When using `MAIN=main.go`, ShardCloud builds the `main.go` file as the entry point. If your package spans multiple files, a package build should be used instead.\n\nTo ensure smooth deployment, it's essential to include the `go.mod` file with the source code. The `go directive` in `go.mod` sets the minimum Go version required by the project. Choose a platform runtime that is equal to or newer than this version. If third-party dependencies are added, run `go mod tidy` and include the resulting `go.sum` file when Go creates it. In this example, only the standard library is used.\n\nWhen listening on the platform's port, read the `PORT` environment variable and use an address like `:8080`. Leaving the host empty allows Go to listen on all network interfaces. A small Go API can be built by creating a folder named `hello-go` and defining the necessary files. Make sure to have Go 1.27 or newer installed locally and a ShardCloud account for the upload process.\n\nThe `go.mod` file should include the module name, Go version, and main package. For this example, the module name is `example.com/hello-go`, the Go version is `1.27.0`, and the main package is `main.go`. The `main.go` file should contain the necessary code to handle HTTP requests and respond with JSON data. The `writeJSON` function is responsible for setting the content type and encoding the response body.\n\nTo deploy the API to ShardCloud, add `.shardcloud` next to `go.mod` and `main.go`. Set `DISPLAY_NAME` to a desired name for the application, `MAIN` to `main.go`, `MEMORY` to the desired memory allocation, `VERSION` to the Go version, and `SUBDOMAIN` to an available subdomain. ShardCloud will compile the source code and start the resulting binary, setting `PORT=80` for the code to read on startup.\n\nCreate a ZIP archive from inside the project folder containing the source code, `go.mod`, and `.shardcloud` configuration file. On macOS or Linux, use the `zip` command, while on Windows, use the `tar` command with PowerShell. Once the ZIP archive is created, upload it to the ShardCloud dashboard under the \"Applications\" section. Choose \"New app\" and upload the `hello-go.zip` file.\n\nAfter uploading the application, check the logs for the message \"Listening on :80\" and open the application's health endpoint (`/health`) on the .shardweb.app URL to verify a successful HTTP 200 response with the expected JSON data. If any build failures or 502 errors occur, diagnose the issue by examining the logs and adjusting the configuration as needed.",
  "summary": "go run . works on your laptop. Then you upload your app and the build log says undefined: writeJSON . Or the build succeeds, but your public URL returns 502 Bad Gateway . Those failures happen at different points. In the first case, the platform never started the app. In the second, the proxy couldn't get a response from it. We'll deploy a small API using Go's standard library, then use the build…",
  "summary_source": "publisher",
  "key_points": [
    "Go application deployment requires considering platform-specific issues",
    "ShardCloud builds entry point from main.go, not package files",
    "Include go.mod and go.sum files for proper Go version and dependencies"
  ],
  "editors_take": null,
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}