Skip to content

Latest commit

 

History

History
615 lines (501 loc) · 39.3 KB

go.md

File metadata and controls

615 lines (501 loc) · 39.3 KB

Go

Blogs

Concurrency

Generics

Iterators

HTTP Server

Auth

Authz

HTTP Client

Metrics

Websocket

CLI

Docker

Event drive applications

NATS

RabbitMQ

AWS

Redis

Aerospike

Lambda

AI

JSON & YAML

PDF

Databases

GraphQL

Microservices

CI & CD

Tools

Raspberry PI

Testing

Profiling

Debugging

Public API's

gRPC

E-Mail

Distributed locking

Cache

Logging

Miscellaneous

Images

Error handling

GUI

Kubernetes

GIS

SSH

NLP

Job interview questions (find out the problem)

https://play.golang.org/p/n3iH7H11Uoe

package main

const N = 3

func main() {
	m := make(map[int]*int)

	for i := 0; i < N; i++ {
		m[i] = &i //A
	}

	for _, v := range m {
		print(*v)
	}
}

https://play.golang.org/p/BW0lY5dW7ZJ

package main

import (
	"io/ioutil"
	"os"
)

func main() {
	f, err := os.Open("file")
	defer f.Close()
	if err != nil {
		return
	}

	b, err := ioutil.ReadAll(f)
	println(string(b))
}

https://play.golang.org/p/zgSTwr035YQ

package main

import (
	"sync"
)

const N = 10

func main() {
	m := make(map[int]int)

	wg := &sync.WaitGroup{}
	mu := &sync.Mutex{}
	wg.Add(N)
	for i := 0; i < N; i++ {
		go func() {
			defer wg.Done()
			mu.Lock()
			m[i] = i
			mu.Unlock()
		}()
	}
	wg.Wait()
	println(len(m))
}

https://play.golang.org/p/6bzWYtdAh9K

package main

func main() {
	s := "123"
	ps := &s
	b := []byte(*ps)
	pb := &b

	s += "4"
	*ps += "5"
	b[1] = '0'

	println(*ps)
	println(string(*pb))
}