Polyglot Programming

Learn C#, Python, and Go through practical examples

Refactoring

Learn the basic of refactoring

go

Exercise

Go

In the Go implementation we can apply some refactoring. Some functions are not placed in a logical place because they are used in multiple places.

Create an util folder and create a file named env.go to contain the functions that have to do with working writing, reading and parsing environment variables.

func ParseEnvFile(path string) (map[string]string, error)

func WriteEnvFile(path string, envVars map[string]string) error

func ResolvePath(path string) (string, error)

Update the files which use these functions.

Solution

Solution
git clone --branch 08-refactoring --single-branch https://github.com/XPRTZ/envtamer.git