Debian Codegraph @

/

debian golang-github-geertjohan-go.incremental 1.0.0-2debian golang-github-geertjohan-go.incremental-dev gomod github.com/GeertJohan/go.incremental debiangoinimakefilemarkdownshellyaml 35 files · 184 symbols
View dependency graph

Depends on

README (full)

go.incremental

Build Status Go package incremental provides typed incremental counters that are type-safe.

Install

go get github.com/GeertJohan/go.incremental

Usage example

This example is also located in the example subdirectory

package main

import (
	"fmt"
	"github.com/GeertJohan/go.incremental"
	"runtime"
)

func main() {
	// use max cpu's
	runtime.GOMAXPROCS(runtime.NumCPU())

	// create new incremental.Int
	i := &incremental.Int{}

	// print some numbers
	fmt.Println(i.Next()) // print 1
	fmt.Println(i.Next()) // print 2
	fmt.Println(i.Next()) // print 3

	// create chan to check if goroutines are done
	done := make(chan int)

	// spawn 4 goroutines
	for a := 0; a < 4; a++ {
		// call goroutine with it's number (0-3)
		go func(aa int) {
			// print 10 incremental numbers
			for b := 0; b < 10; b++ {
				fmt.Printf("routine %d: %d\n", aa, i.Next())
			}
			// signal done
			done <- aa
		}(a)
	}

	// wait until all goroutines are done
	for a := 0; a < 4; a++ {
		fmt.Printf("goroutine %d done\n", <-done)
	}
	fmt.Println("all done")
}
dir debian/
dir example/
dir gen/
file .gitignore
file LICENSE
file README.md
file doc.go
file go.mod
file int.go
file int16.go
file int16_test.go
file int32.go
file int32_test.go
file int64.go
file int64_test.go
file int8.go
file int8_test.go
file int_test.go
file uint.go
file uint16.go
file uint16_test.go
file uint32.go
file uint32_test.go
file uint64.go
file uint64_test.go
file uint8.go
file uint8_test.go
file uint_test.go