...

Source file src/code.rocketnine.space/tslocum/fibs/util.go

Documentation: code.rocketnine.space/tslocum/fibs

     1  package fibs
     2  
     3  import (
     4  	"fmt"
     5  	"io"
     6  	"strings"
     7  	"time"
     8  	"unicode"
     9  )
    10  
    11  var (
    12  	StatusWriter io.Writer
    13  	GameWriter   io.Writer
    14  )
    15  
    16  func l(s string) {
    17  	s = strings.TrimRightFunc(s, unicode.IsSpace)
    18  	s = strings.ReplaceAll(s, "\a", "")
    19  	s = strings.ReplaceAll(s, "\r", "")
    20  
    21  	m := time.Now().Format("15:04") + " " + s
    22  	if StatusWriter != nil {
    23  		StatusWriter.Write([]byte(m + "\n"))
    24  		return
    25  	}
    26  
    27  	fmt.Println(m)
    28  }
    29  
    30  func lf(format string, a ...interface{}) {
    31  	l(fmt.Sprintf(format, a...))
    32  }
    33  
    34  func lg(s string) {
    35  	s = strings.TrimRightFunc(s, unicode.IsSpace)
    36  	s = strings.ReplaceAll(s, "\a", "")
    37  	s = strings.ReplaceAll(s, "\r", "")
    38  
    39  	m := time.Now().Format("15:04") + " " + s
    40  	if GameWriter != nil {
    41  		GameWriter.Write([]byte(m + "\n"))
    42  		return
    43  	}
    44  
    45  	fmt.Println(m)
    46  }
    47  

View as plain text