Composition over inheritance, and Go's approach
dev.to·15h·
Discuss: DEV
🔧Code Refactoring Patterns
Preview
Report Post

Preface

I estimate that you only need a basic understanding of Go to be able to read almost all Go code. The compiler is highly opinionated, and holds you accountable for any shenanigans. Forcing you to write consistent and simple code; almost no style deviations, and almost no syntax sugar. Short term convenience is traded in for long-term clarity and reliability, as seen here:

package main

import "container/list" // ERROR: Import not used — we don't do retours...

func main() {
err := wrongStuff() // ERROR: You gotta face your errors man...
}

func crazyFunc() string
{ // ERROR: That curly brace should not be there...
if true {

}
// ERROR: Does not seem like that "else" is connected well...
else {

}

return 5 + "helloWorld" // ERROR: No implicit type conversions, show me ...

Similar Posts

Loading similar posts...