github.com/fufuok/balancer@v1.0.0/examples/quickstart/main.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/fufuok/balancer"
     7  )
     8  
     9  func main() {
    10  	wNodes := map[string]int{
    11  		"🍒": 5,
    12  		"🍋": 3,
    13  		"🍉": 1,
    14  		"🥑": 0,
    15  	}
    16  	balancer.Update(wNodes)
    17  
    18  	// result of smooth selection is similar to: 🍒 🍒 🍒 🍋 🍒 🍋 🍒 🍋 🍉
    19  	for i := 0; i < 9; i++ {
    20  		fmt.Print(balancer.Select(), " ")
    21  	}
    22  	fmt.Println()
    23  }