learning_go/headFirst/colors/main.go
2025-10-29 20:46:31 +03:00

49 lines
1.2 KiB
Go

package main
import (
"bytes"
"fmt"
"sort"
_ "github.com/fatih/color"
)
func main() {
var buffer bytes.Buffer
// yellow := color.New(color.FgHiYellow).PrintFunc()
infos := map[string]string{
"front_addr": "strings.Split(osdDevice.Info.FrontAddr,)[0]",
"ceph_release/version": "osdDevice.Info.CephRelease",
"cpu": "osdDevice.Info.CPU",
"hostname": "osdDevice.Info.Hostname",
"default_device_class": "osdDevice.Info.DefaultDeviceClass",
"devices": "osdDevice.Info.Devices",
"distro_description": "osdDevice.Info.DistroDescription",
"journal_rotational": "osdDevice.Info.JournalRotational",
"rotational": "osdDevice.Info.Rotational",
"kernel_version": "osdDevice.Info.KernelVersion",
"mem_swap_kb": "osdDevice.Info.MemSwapKb",
"mem_total_kb": "osdDevice.Info.MemTotalKb",
"osd_data": "osdDevice.Info.OsdData",
"osd_objectstore": "osdDevice.Info.OsdObjectstore",
}
buffer.WriteString(fmt.Sprintf("this is test"))
var infokeys []string
// _width := []int{0,0,0,0,0,0}
for k := range infos {
// fmt.Println(k)
infokeys = append(infokeys, k)
}
sort.Strings(infokeys)
for k,v := range infokeys {
fmt.Println(k,v)
}
}