Back to course

Go and Environment Variables

Go (Golang) for Cloud-Native Microservices

Twelve-Factor Apps

Cloud-native apps should be configured via environment variables.

Reading Envs:

go dbURL := os.Getenv("DATABASE_URL") if dbURL == "" { dbURL = "localhost:5432" // Default }

Avoid hardcoding secrets or configurations in your Go code.