diff --git a/go.mod b/go.mod index 3d7b97e..00dedcd 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/dkorunic/iSMC go 1.18 require ( + github.com/fvbommel/sortorder v1.0.2 github.com/jedib0t/go-pretty v4.3.0+incompatible github.com/panotza/gosmc v1.0.0 github.com/sirupsen/logrus v1.8.1 @@ -20,6 +21,6 @@ require ( github.com/oklog/ulid v1.3.1 // indirect github.com/rivo/uniseg v0.2.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - go.mongodb.org/mongo-driver v1.8.4 // indirect - golang.org/x/sys v0.0.0-20220403020550-483a9cbc67c0 // indirect + go.mongodb.org/mongo-driver v1.9.0 // indirect + golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12 // indirect ) diff --git a/go.sum b/go.sum index 8d75476..8f547ed 100644 --- a/go.sum +++ b/go.sum @@ -6,6 +6,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fvbommel/sortorder v1.0.2 h1:mV4o8B2hKboCdkJm+a7uX/SIpZob4JzUpc5GGnM45eo= +github.com/fvbommel/sortorder v1.0.2/go.mod h1:uk88iVf1ovNn1iLfgUVU2F9o5eO30ui720w+kxuqRs0= github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= github.com/go-openapi/errors v0.20.2 h1:dxy7PGTqEh94zj2E3h1cUmQQWiM1+aeCROfAr02EmK8= github.com/go-openapi/errors v0.20.2/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= @@ -64,6 +66,8 @@ github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7Jul go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4xhp5Zvxng= go.mongodb.org/mongo-driver v1.8.4 h1:NruvZPPL0PBcRJKmbswoWSrmHeUvzdxA3GCPfD/NEOA= go.mongodb.org/mongo-driver v1.8.4/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY= +go.mongodb.org/mongo-driver v1.9.0 h1:f3aLGJvQmBl8d9S40IL+jEyBC6hfLPbJjv9t5hEM9ck= +go.mongodb.org/mongo-driver v1.9.0/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= @@ -76,6 +80,8 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220403020550-483a9cbc67c0 h1:PgUUmg0gNMIPY2WafhL/oLyQGw+kdTNPlVWOjltpp3w= golang.org/x/sys v0.0.0-20220403020550-483a9cbc67c0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12 h1:QyVthZKMsyaQwBTJE04jdNN0Pp5Fn9Qga0mrgxyERQM= +golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/hid/hid.go b/hid/hid.go index 9c24b04..16f9879 100644 --- a/hid/hid.go +++ b/hid/hid.go @@ -27,6 +27,7 @@ import ( "github.com/jedib0t/go-pretty/table" ) +import "github.com/fvbommel/sortorder" const ( SensorSeparator = ":" @@ -67,9 +68,7 @@ func printGeneric(t table.Writer, unit string, cStr *C.char) { } } - sort.Slice(stats, func(i, j int) bool { - return stats[i].Name < stats[j].Name - }) + sort.Slice(stats, func(i, j int) bool { return sortorder.NaturalLess(stats[i].Name, stats[j].Name) }) for _, v := range stats { name := v.Name diff --git a/smc/smc.go b/smc/smc.go index f3da7ed..1ce852f 100644 --- a/smc/smc.go +++ b/smc/smc.go @@ -24,6 +24,7 @@ import ( "strconv" "strings" + "github.com/fvbommel/sortorder" "github.com/jedib0t/go-pretty/table" "github.com/panotza/gosmc" log "github.com/sirupsen/logrus" @@ -55,7 +56,7 @@ func printGeneric(t table.Writer, unit string, smcSlice []SensorStat) { } defer gosmc.SMCClose(c) - sort.Slice(smcSlice, func(i, j int) bool { return smcSlice[i].Key < smcSlice[j].Key }) + sort.Slice(smcSlice, func(i, j int) bool { return sortorder.NaturalLess(smcSlice[i].Desc, smcSlice[j].Desc) }) for _, v := range smcSlice { key := v.Key