# Go

Source : https://webgune.cloud/en-us/docs/web-go · Mis à jour le 2026-10-27

# Go

A `go.mod` file at the root is enough to trigger automatic compilation of the binary.

## net/http

```go
package main

import (
    "fmt"
    "net/http"
    "os"
)

func main() {
    port := os.Getenv("PORT")
    if port == "" {
        port = "8080"
    }
    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        fmt.Fprint(w, "Hello Webgune")
    })
    http.ListenAndServe(":"+port, nil)
}
```

## Gin

```go
package main

import (
    "os"
    "github.com/gin-gonic/gin"
)

func main() {
    r := gin.Default()
    r.GET("/health", func(c *gin.Context) {
        c.JSON(200, gin.H{"ok": true})
    })

    port := os.Getenv("PORT")
    if port == "" {
        port = "8080"
    }
    r.Run("0.0.0.0:" + port)
}
```

## Private modules

If your project depends on a private Go module, configure `GOPRIVATE` and an access token via the service's environment variables, or switch to a [Dockerfile](/docs/docker-dockerfile) deployment for full control over the build step.
