Skip to content

heuristicwave/buildingBlockchain

Repository files navigation

buildingBlockchain

Building Blockchain with Go 👣

Tutorial

Development

rest.go

  1. url 정의
  2. router 만들기 (handler)
  3. controller 만들기

Concepts

In Go, nil is the zero value for pointers, interfaces, maps, slices, channels and function types, representing an uninitialized value. 함수명을 대문자로 시작하면 외부에서 호출 가능

Channels

// Only Send Channel
func send(c chan<- int) {
	for i := range [10]int{} {
		fmt.Printf(">> sending %d <<\n", i)
		c <- i
		fmt.Printf(">> sent %d <<\n", i)
	}
	close(c) // avoid deadlock
}

// Only Receive Channel
func receive(c <-chan int) {
	for {
		time.Sleep(10 * time.Second)
		a, ok := <-c
		if !ok {
			fmt.Println("Done")
			break
		}
		fmt.Printf("|| received %d ||\n", a)
	}
}

func main() {
	c := make(chan int, 10) // Buffer Channel
	go send(c)
	receive(c)
}

Testing

go test ./... -v

Coverage

# create profile
go test -v -coverprofile cover.out ./...

# visualize
go tool cover -html=cover.out

Tools

About

Building Blockchain with Go 👣

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published