OMC's Blog

WIP- Go for Javascript Developers

March 12, 2019


Variable declaration is as is:

var name string
name = "Oguzhan"

const constant = 3.14

When in a scope (between curly braces), you can utilize type inference

func main() {
  name := "Oguzhan"

Built in types

bool string
int  int8  int16  int32  int64
uint uint8 uint16 uint32 uint64 uintptr
byte // alias for uint8
rune // alias for int32
float32 float64
complex64 complex128

- No semicolon at the end of the instructions
- There is no `try catch` mechanism in Go. Manuel error checking

res, err = call()
if err != nil {
  • Functions may return multiple values
func helloWorld() -> string, error {
  return "Hello World", nil
  • There is no concept of class. Use struct instead
type Car struct {
  year int
  model string
  brand string
  color string

You can add methods to the struct

func (c Car) run () {
  fmt.Println("Car is running")

You can mutate existing properties of a struct

func (c *Car) changeColor(color string) {
  c.color = color

Oguzhan Murat Cakmak, starting his software career in Istanbul and advancing through roles in San Francisco at Uber and Hims&Hers, now does remote work from Kaş, Antalya, balancing his passion for technology with interests in kitesurfing, diving, hiking, and exploring diverse content on podcasts. Follow him on Twitter and Instagram


    Loading Webmentions...