mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 17:08:38 +00:00
41 lines
557 B
Go
41 lines
557 B
Go
package main
|
|
|
|
import (
|
|
"strconv"
|
|
"encoding/json"
|
|
"log"
|
|
"strings"
|
|
)
|
|
|
|
func maybeSuffix(counter int) string {
|
|
if counter == 0 {
|
|
return ""
|
|
}
|
|
|
|
return strconv.Itoa(counter+1)
|
|
}
|
|
|
|
func titleCase(s string) string {
|
|
return strings.ToUpper(s[0:1]) + s[1:]
|
|
}
|
|
|
|
func prettyPrint(obj interface{}) {
|
|
jb, err := json.MarshalIndent(obj, "", " ")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
log.Println(string(jb))
|
|
}
|
|
|
|
func ifv[T any](condition bool, trueval T, falseval T) T {
|
|
if condition {
|
|
return trueval
|
|
}
|
|
return falseval
|
|
}
|
|
|
|
func addr[T any](s T) *T {
|
|
return &s
|
|
}
|