Codebase list golang-github-vbauerster-mpb / ba6a2b0 decor / name.go
ba6a2b0

Tree @ba6a2b0 (Download .tar.gz)

name.go @ba6a2b0raw · history · blame

package decor

// StaticName returns name decorator.
//
//	`name` string to display
//
//	`wcc` optional WC config
func StaticName(name string, wcc ...WC) Decorator {
	return Name(name, wcc...)
}

// Name returns name decorator.
//
//	`name` string to display
//
//	`wcc` optional WC config
func Name(name string, wcc ...WC) Decorator {
	var wc WC
	for _, widthConf := range wcc {
		wc = widthConf
	}
	wc.BuildFormat()
	return DecoratorFunc(func(s *Statistics, widthAccumulator chan<- int, widthDistributor <-chan int) string {
		return wc.FormatMsg(name, widthAccumulator, widthDistributor)
	})
}