Wednesday, 9 July 2025

Use .env File as a Local Substitute for Parameter Store

This is the simplest and most common approach for local development:

Idea:

  • If running locally, load config from .env

  • If running in production/staging, fetch from AWS Parameter Store

Example

import ( "os" ) // Load parameter based on environment func getParameter(name string) string { if os.Getenv("ENV") == "local" { // Load from .env or environment variable return os.Getenv(name) } // In non-local environments, load from AWS SSM val, err := getFromSSM(name) // implement this function if err != nil { panic(err) } return val }

Your .env file would look like:

ENV=local CLIENT_ID_BURTON=abc123 CLIENT_SECRET_BURTON=xyz456

Use github.com/joho/godotenv to load it

godotenv.Load()

Tuesday, 8 July 2025

Testing - show cover in Golang

go test ./service --cover

go test ./service --cover ./..                 

go tool cover -func=coverage.out

Wednesday, 2 July 2025

Meaning of command: export PATH=/usr/bin:$PATH

What does this command do?

export PATH=/usr/bin:$PATH

This command adds /usr/bin to the beginning of your PATH environment variable.

What is PATH?

PATH is an environment variable that tells your shell (like Bash or Zsh) where to look for programs when you type a command:

Your system looks through all the folders listed in PATH, in order, to find the python program.

What does /usr/bin:$PATH mean?

  • /usr/bin is a directory where many system programs are stored.

  • $PATH is the current list of directories the shell checks.

Why use this?

Sometimes you want to make sure a specific version of a program (like one in /usr/bin) runs before others. Putting /usr/bin at the beginning gives it priority.

Summary

The command ensures that when you run a command, your system will look in /usr/bin first before checking other locations in the PATH.

Golang Advanced Interview Q&A