mirror of
https://github.com/wahyd4/forego.git
synced 2026-08-09 05:07:05 +10:00
Move mutex onto OutletFactory
It's bad form for the mutex to live in the global namespace when it doesn't need to.
This commit is contained in:
@@ -13,6 +13,8 @@ import (
|
||||
type OutletFactory struct {
|
||||
Outlets map[string]*Outlet
|
||||
Padding int
|
||||
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
type Outlet struct {
|
||||
@@ -22,8 +24,6 @@ type Outlet struct {
|
||||
Factory *OutletFactory
|
||||
}
|
||||
|
||||
var mx sync.Mutex
|
||||
|
||||
var colors = []ct.Color{
|
||||
ct.Cyan,
|
||||
ct.Yellow,
|
||||
@@ -68,8 +68,8 @@ func (of *OutletFactory) ErrorOutput(str string) {
|
||||
|
||||
// Write out a single coloured line
|
||||
func (of *OutletFactory) WriteLine(left, right string, leftC, rightC ct.Color, isError bool) {
|
||||
mx.Lock()
|
||||
defer mx.Unlock()
|
||||
of.Lock()
|
||||
defer of.Unlock()
|
||||
|
||||
ct.ChangeColor(leftC, true, ct.None, false)
|
||||
formatter := fmt.Sprintf("%%-%ds | ", of.Padding)
|
||||
|
||||
Reference in New Issue
Block a user