summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean E. Russell <ser@ser1.net>2021-05-03 11:43:13 -0500
committerSean E. Russell <ser@ser1.net>2021-05-03 11:43:13 -0500
commit162ed50189ea602c857738789f5a8dd4adb11180 (patch)
tree2be775575b881213e00dc446b09dc18aa3727a83
parente3cd3ebe5e960896b9515df054cea75df6ce2c89 (diff)
parent5a063376b0d63bfe57f35169dc1c754d3f7d16b0 (diff)
Merge branch 'go1.16'
-rw-r--r--.gitignore1
-rw-r--r--CHANGELOG.md20
-rw-r--r--README.md29
-rw-r--r--cmd/gotop/main.go24
-rw-r--r--colorschemes/registry.go2
-rw-r--r--config.go6
-rw-r--r--devices/devices.go2
-rw-r--r--devices/smc.go245
-rw-r--r--devices/smc.tsv (renamed from devices/data/smc.tsv)0
-rw-r--r--devices/temp_darwin.go15
-rw-r--r--devices/temp_darwin_test.go23
-rw-r--r--dicts/de_DE.toml (renamed from translations/dicts/de_DE.toml)0
-rw-r--r--dicts/en_US.toml (renamed from translations/dicts/en_US.toml)0
-rw-r--r--dicts/eo.toml (renamed from translations/dicts/eo.toml)0
-rw-r--r--dicts/fr.toml (renamed from translations/dicts/fr.toml)0
-rw-r--r--dicts/ru_RU.toml (renamed from translations/dicts/ru_RU.toml)0
-rw-r--r--dicts/tt_TT.toml (renamed from translations/dicts/tt_TT.toml)0
-rw-r--r--dicts/zh_CN.toml (renamed from translations/dicts/zh_CN.toml)0
-rw-r--r--go.mod7
-rw-r--r--go.sum21
-rw-r--r--layout/layout.go2
-rw-r--r--logging/logging.go2
-rw-r--r--termui/table.go2
-rw-r--r--translations/dicts.go471
-rw-r--r--widgets/help.go2
25 files changed, 107 insertions, 767 deletions
diff --git a/.gitignore b/.gitignore
index 9588e08..f08e462 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,4 @@ build/gotop_*
build.log
tmp/
+dist/
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 99bd79b..56f8bf6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
> - **Fixed**: for any bug fixes.
> - **Security**: in case of vulnerabilities.
+## [4.1.2]
+
+### Added
+
+- French and Russion translations (thank you @lourkeur and @talentlessguy!)
+- nvidia support merged in from extension
+- remote support merged in from extension
+
+### Changed
+
+- Upgrade to Go 1.16. This eliminates go:generate for the language files, which
+ means gotop no longer builds with Go < 1.16.
+
+### Fixed
+
+- German translation corrected (thanks @plgruener!)
+- Extra spaces in help text (#167)
+- Crash with German translation (#166)
+- Bad error message for missing layouts (#164)
+
## [4.1.1] 2021-02-03
### Added
diff --git a/README.md b/README.md
index 2b29c40..6abde81 100644
--- a/README.md
+++ b/README.md
@@ -35,13 +35,16 @@ If you install gotop by hand, or you download or create new layouts or colorsche
```
- **OSX**: gotop is in *homebrew-core*. `brew install gotop`. Make sure to uninstall and untap any previous installations or taps.
- **Prebuilt binaries**: Binaries for most systems can be downloaded from [the github releases page](https://github.com/xxxserxxx/gotop/releases). RPM and DEB packages are also provided.
-- **Source**: gotop requires Go >= 1.14: `go get -u github.com/xxxserxxx/gotop/v4/cmd/gotop`
+- **Prebuild binaries with extensions**:
+ - [NVidia GPU support](https://github.com/xxxserxxx/gotop-nvidia/releases)
+ - [Remote gotop support](https://github.com/xxxserxxx/gotop-remote/releases)
+- **Source**: This requires Go >= 1.16. `go get -u github.com/xxxserxxx/gotop/v4/cmd/gotop`
### Extension builds
Extensions have proven problematic; go plugins are not usable in real-world cases, and the solution I had running for a while was hacky, at best. Consequently, extensions have been moved into the main code base for now.
-- nvidia support: requires the `enable` flag. Detecting nvidia hardware, or rather, the absense of NVidia hardware, can take seconds; this greatly slows down gotop's start-up time. To avoid this, the NVidia code will not be run unless it has been enabled with the `--enable nvidia` runtime flag.
+- nvidia support: use the `--nvidia` flag to enable. You must have the `nvidia- smi` package installed, and gotop must be able to find the `nvidia-smi` executable, for this to work.
- remote: allows gotop to pull sensor data from applications exporting Prometheus metrics, including remote gotop instances themselves.
### Console Users
@@ -57,12 +60,12 @@ setfont Lat15-VGA16-braille.psf
This is the download & compile approach.
-gotop should build with most versions of Go. If you have a version other than 1.14 installed, remove the `go` line at the end of `go.mod` and it should work.
+gotop requires Go 1.16 or later to build, as it relies on the embed feature released with 1.16; a library it uses, lingo, uses both embed and the `io/fs` package. For a version of gotop that builds with earlier versions, check out one of the tags prior to v4.2.0.
```shell
git clone https://github.com/xxxserxxx/gotop.git
cd gotop
-sed -i '/^go/d' go.mod # Do this if you have go != 1.14
+# This ugly SOB gets a usable version from the git tag list
VERS="$(git tag -l --sort=-v:refname | sed 's/v\([^-].*\)/\1/g' | head -1 | tr -d '-' ).$(git describe --long --tags | sed 's/\([^-].*\)-\([0-9]*\)-\(g.*\)/r\2.\3/g' | tr -d '-')"
DAT=$(date +%Y%m%dT%H%M%S)
go build -o gotop \
@@ -70,13 +73,19 @@ go build -o gotop \
./cmd/gotop
```
-Move `gotop` to somewhere in your `$PATH`.
+If you want to compact the executable as much as possible on Linux, change the `ldflags` line to this:
+
+```
+-ldflags "-X main.Version=v${VERS} -X main.BuildDate=${DAT} -extldflags '-s -w'" \
+```
+
+Now move the `gotop` executable to somewhere in your `$PATH`.
If Go is not installed or is the wrong version, and you don't have root access or don't want to upgrade Go, a script is provided to download Go and the gotop sources, compile gotop, and then clean up. See `scripts/install_without_root.sh`.
#### go generate
-Apple SMC tags are embedded in a text file that is compiled into the executable; the same happens with the language translations. When the file `devices/data/sm.tsv` or any translations in `translations/dicts/` change, `go generate` should be re-run.
+With Go 1.16, it is no longer necessary to call `go generate`. Translations and Apple SMC tags are emded with `go:embed`.
## Usage
@@ -119,7 +128,8 @@ For more information on other topics, see:
- [goreleaser/nfpm](https://github.com/goreleaser/nfpm)
- [distatus/battery](https://github.com/distatus/battery)
- [VictoriaMetrics/metrics](https://github.com/VictoriaMetrics/metrics) Check this out! The API is clean, elegant, introduces many fewer indirect dependencies than the Prometheus client, and adds 50% less size to binaries.
-- [lingo-toml](https://github.com/jdkeke142/lingo-toml) provides the translation support library.
+- [lingo](https://github.com/xxxserxxx/lingo) is forked from [jdkeke142's](https://github.com/jdkeke142/lingo-toml) lingo, which was in turn forked from [kortemy's](https://github.com/kortemy/lingo) original project.
+
## History
@@ -130,12 +140,13 @@ For more information on other topics, see:
I obviously think gotop is the Bee's Knees, but there are many alternatives. Many of these have been around for years. All of them are terminal-based tools.
- Grandpa [top](http://sourceforge.net/projects/unixtop/). Written 36 years ago, C, installed by default on almost every Unix descendant.
+- [bashtop](https://github.com/aristocratos/bashtop), in pure bash! Beautiful and space efficient, and [deserves special comment](docs/bashtop.md).
+- [bpytop](https://github.com/aristocratos/bpytop), aristocratos, the author of bashtop, rewrote it in Python in mid-2020; it's the same beautiful interface, and a very nice alternative.
- [htop](https://hisham.hm/htop/). A prettier top. Similar functionality. 16 years old!
- [atop](https://www.atoptool.nl/). Detailed process-focused inspection with a table-like view. Been around for 9 long years.
- [iftop](http://www.ex-parrot.com/~pdw/iftop/), a top for network connections. More than just data transfer, iftop will show what interfaces are connecting to what IP addresses. Requires root access to run.
- [iotop](http://guichaz.free.fr/iotop/), top for disk access. Tells you *which* processes are writing to and from disk space, and how much. Also requires root access to run.
- [nmon](http://nmon.sourceforge.net) a dashboard style top; widgets can be dynamically enabled and disabled, pure ASCII rendering, so it doesn't rely on fancy character sets to draw bars.
-- [bashtop](https://github.com/aristocratos/bashtop), in pure bash! Beautiful and space efficient, and [deserves special comment](docs/bashtop.md). If you use anything other than gotop, I'd recommend bashtop.
- [ytop](https://github.com/cjbassi/ytop), a rewrite of gotop (ca. 3.0) in Rust. Same great UI, different programming language.
- [slabtop](https://gitlab.com/procps-ng/procps), part of procps-ng, looks like top but provides kernel slab cache information! Requires root.
- [systemd-cgtop](https://www.github.com/systemd/systemd), comes with systemd (odds are your system uses systemd, so this is already installed), provides a resource use view of control groups -- basically, which services are using what resources. Does *not* require root to run.
@@ -145,7 +156,7 @@ I obviously think gotop is the Bee's Knees, but there are many alternatives. Man
### A comment on clones
-In a chat room I heard someone refer to gotop as "another one of those fancy language rewrites people do." I'm not the original author of gotop, so it's easy to not take offense, but I'm going on record as saying that I disagree with that sentiment: I think these rewrites are valuable, useful, and healthy to the community. They increase software diversity at very little [cost to users](https://en.wikipedia.org/wiki/Information_overload), and are a sort of evolutionary mechanism: as people do rewrites, some are worse, but some are better, and users benefit. Rewrites provide options, which fight against [monocultures](https://github.com). As importantly, most developers are really only fluent in a couple of programming languages. We all have *familiarity* with a dozen, and may even have extensive experience with a half-dozen, but if you don't constantly use a language, you tend to forget the extended library APIs, your development environment isn't tuned, you're rusty with using the tool sets, and you may have forgotten a lot of the language peculiarities and gotchas. The barrier to entry for contributing to a software project -- to simply finding and fixing a bug -- in a language you're not intimate with can be very high. It gets much worse if the project owner is a stickler for quality and style. So I believe that gotop's original author's decision to rewrite his project in Rust is a net positive. He probably made fewer design mistakes in ytop (we always do, on the second rewrite), and Rust developers -- who may have hesitated learning or brushing up on Go to submit an improvement -- have another project to which they can contribute.
+In a chat room I heard someone refer to gotop as "another one of those fancy language rewrites people do." I'm not the original author of gotop, so it's easy to not take offense, but I'm going on record as saying that I disagree with that sentiment: I think these rewrites are valuable, useful, and healthy to the community. They increase software diversity at very little [cost to users](https://en.wikipedia.org/wiki/Information_overload), and are a sort of evolutionary mechanism: as people do rewrites, some are worse, but some are better, and users benefit. Rewrites provide options, which fight against [monocultures](https://github.com). As importantly, most developers are really only fluent in a couple of programming languages. We all have *familiarity* with a dozen, and may even have extensive experience with a half-dozen, but if you don't constantly use a language, you tend to forget the extended library APIs, your development environment isn't tuned, you're rusty with using the tool sets, and you may have forgotten a lot of the language peculiarities and gotchas. The barrier to entry for contributing to a software project -- to simply finding and fixing a bug -- in a language you're not intimate with can be very high. It gets much worse if the project owner is a stickler for a particular style. So I believe that gotop's original author's decision to rewrite his project in Rust is a net positive. He probably made fewer design mistakes in ytop (we always do, on the second rewrite), and Rust developers -- who may have hesitated learning or brushing up on Go to submit an improvement -- have another project to which they can contribute.
Diversity is good. Don't knock the free stuff.
diff --git a/cmd/gotop/main.go b/cmd/gotop/main.go
index 94f03a8..7f08626 100644
--- a/cmd/gotop/main.go
+++ b/cmd/gotop/main.go
@@ -5,6 +5,7 @@ import (
"flag"
"fmt"
"io"
+ "io/fs"
"io/ioutil"
"log"
"net/http"
@@ -22,7 +23,7 @@ import (
jj "github.com/cloudfoundry-attic/jibber_jabber"
ui "github.com/gizak/termui/v3"
"github.com/shibukawa/configdir"
- "github.com/xxxserxxx/lingo"
+ "github.com/xxxserxxx/lingo/v2"
"github.com/xxxserxxx/opflag"
"github.com/xxxserxxx/gotop/v4"
@@ -30,7 +31,6 @@ import (
"github.com/xxxserxxx/gotop/v4/devices"
"github.com/xxxserxxx/gotop/v4/layout"
"github.com/xxxserxxx/gotop/v4/logging"
- "github.com/xxxserxxx/gotop/v4/translations"
w "github.com/xxxserxxx/gotop/v4/widgets"
)
@@ -126,14 +126,22 @@ func parseArgs() error {
case "widgets":
fmt.Println(tr.Value("help.widgets"))
case "langs":
- vs, err := translations.AssetDir("")
+ err := fs.WalkDir(gotop.Dicts, ".", func(pth string, info fs.DirEntry, err error) error {
+ if err != nil {
+ return err
+ }
+ if info.IsDir() { // We skip these
+ return nil
+ }
+ fileName := info.Name()
+ if !strings.HasSuffix(fileName, ".toml") {
+ fmt.Println(strings.TrimSuffix(fileName, ".toml"))
+ }
+ return nil
+ })
if err != nil {
return err
}
- for _, v := range vs {
- v = strings.TrimSuffix(v, ".toml")
- fmt.Println(v)
- }
default:
fmt.Printf(tr.Value("error.unknownopt", *list))
os.Exit(1)
@@ -366,7 +374,7 @@ func main() {
}
func run() int {
- ling, err := lingo.New("en_US", "", translations.AssetFile())
+ ling, err := lingo.New("en_US", ".", gotop.Dicts)
if err != nil {
fmt.Printf("failed to load language files: %s\n", err)
return 2
diff --git a/colorschemes/registry.go b/colorschemes/registry.go
index aa6e1f9..663ccab 100644
--- a/colorschemes/registry.go
+++ b/colorschemes/registry.go
@@ -6,7 +6,7 @@ import (
"path/filepath"
"strings"
- "github.com/xxxserxxx/lingo"
+ "github.com/xxxserxxx/lingo/v2"
"github.com/shibukawa/configdir"
)
diff --git a/config.go b/config.go
index 30c76db..23754e4 100644
--- a/config.go
+++ b/config.go
@@ -6,6 +6,7 @@ package gotop
import (
"bufio"
"bytes"
+ "embed"
"fmt"
"io"
"io/ioutil"
@@ -19,9 +20,12 @@ import (
"github.com/shibukawa/configdir"
"github.com/xxxserxxx/gotop/v4/colorschemes"
"github.com/xxxserxxx/gotop/v4/widgets"
- "github.com/xxxserxxx/lingo"
+ "github.com/xxxserxxx/lingo/v2"
)
+//go:embed "dicts/*.toml"
+var Dicts embed.FS
+
// CONFFILE is the name of the default config file
const CONFFILE = "gotop.conf"
diff --git a/devices/devices.go b/devices/devices.go
index 1574354..f9c6265 100644
--- a/devices/devices.go
+++ b/devices/devices.go
@@ -2,7 +2,7 @@ package devices
import (
"log"
- "github.com/xxxserxxx/lingo"
+ "github.com/xxxserxxx/lingo/v2"
)
const (
diff --git a/devices/smc.go b/devices/smc.go
deleted file mode 100644
index 5d4133d..0000000
--- a/devices/smc.go
+++ /dev/null
@@ -1,245 +0,0 @@
-// Code generated by go-bindata. (@generated) DO NOT EDIT.
-
- //Package devices generated by go-bindata.// sources:
-// devices/data/smc.tsv
-package devices
-
-import (
- "bytes"
- "compress/gzip"
- "fmt"
- "io"
- "io/ioutil"
- "os"
- "path/filepath"
- "strings"
- "time"
-)
-
-func bindataRead(data []byte, name string) ([]byte, error) {
- gz, err := gzip.NewReader(bytes.NewBuffer(data))
- if err != nil {
- return nil, fmt.Errorf("read %q: %v", name, err)
- }
-
- var buf bytes.Buffer
- _, err = io.Copy(&buf, gz)
- clErr := gz.Close()
-
- if err != nil {
- return nil, fmt.Errorf("read %q: %v", name, err)
- }
- if clErr != nil {
- return nil, err
- }
-
- return buf.Bytes(), nil
-}
-
-type asset struct {
- bytes []byte
- info os.FileInfo
-}
-
-type bindataFileInfo struct {
- name string
- size int64
- mode os.FileMode
- modTime time.Time
-}
-
-// Name return file name
-func (fi bindataFileInfo) Name() string {
- return fi.name
-}
-
-// Size return file size
-func (fi bindataFileInfo) Size() int64 {
- return fi.size
-}
-
-// Mode return file mode
-func (fi bindataFileInfo) Mode() os.FileMode {
- return fi.mode
-}
-
-// ModTime return file modify time
-func (fi bindataFileInfo) ModTime() time.Time {
- return fi.modTime
-}
-
-// IsDir return file whether a directory
-func (fi bindataFileInfo) IsDir() bool {
- return fi.mode&os.ModeDir != 0
-}
-
-// Sys return file is sys mode
-func (fi bindataFileInfo) Sys() interface{} {
- return nil
-}
-
-var _smcTsv = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x74\x95\xc1\x72\xab\x3a\x0f\xc7\xd7\x3d\x4f\xc1\xf0\x00\x1d\x4c\x92\x36\x67\x09\xa6\x05\x66\x42\xa2\x09\x29\x5f\x77\xdf\x10\xca\x6d\x99\x43\x02\x03\xf4\x9e\xe6\xed\xef\x58\xc6\xc6\x36\x64\xe9\x9f\x24\xdb\x92\xfe\xb2\xed\x13\x7d\xa7\xf6\x83\x0d\x2f\x34\xb6\x28\xbc\xd9\xbf\x18\x29\x4c\xe2\x80\xfd\x60\x53\x78\xb3\x88\x05\x5d\xf3\x53\x5d\xaa\xe1\xc6\x0d\x91\x34\x44\x65\x3e\xf4\xd5\xf5\x0f\xe7\xc1\x14\x90\x17\x7f\xf2\xcf\x92\xe3\x17\x81\xf9\xf2\x55\x5b\x12\x3a\x2e\x69\xd3\x95\x23\x73\x35\xe6\x22\x5b\x69\x6c\x85\x6c\xad\xb1\x35\xb2\x8d\xc6\x36\xc8\x9e\x34\xf6\x84\xec\x59\x63\xcf\xc8\xb6\x1a\xdb\x22\xf3\xe6\xc9\x5a\x5e\x3d\x3c\x72\xe3\x2c\xe3\xc9\x46\x44\xf9\x5c\xa3\x7c\x24\x92\x06\xad\x7c\x24\x98\x02\x94\xf2\x11\x51\x3e\x5e\x07\xf2\xaa\x2d\xfd\xf9\x66\xd3\x15\xfc\xd9\x8e\x93\x2d\x95\x0a\x48\x3d\x0e\x0a\x13\x78\x06\x08\x65\x48\x38\x4a\x24\x2c\x0c\x12\xa2\x68\x42\x78\xd3\x73\x0e\x51\x1a\x0c\x07\x15\x66\x15\x12\x13\xa0\xa8\x18\x50\x6b\x12\x92\x25\xda\x3b\xa9\xfd\x60\x27\xe5\xa5\xe9\x6e\xfa\x39\x09\x1e\x9f\x94\x17\xcb\xcf\x59\x21\x50\x4e\x09\xd1\x21\x16\x2e\xd9\x6a\xd0\xe7\x9e\xbf\x75\xc8\x3d\xc5\x69\x56\xd2\x7c\x7c\xd7\xa5\xdc\xd5\xc4\xe3\xbe\x06\x16\x3b\x9b\x18\xbd\xf7\x58\x97\x7d\xd3\x0d\x5f\xe7\xae\xfa\xf8\x2c\x45\x39\xf6\x98\x88\x6a\x90\x79\xf2\x19\xd9\x93\xfb\x0e\xe3\xd6\xac\x5b\x09\x8d\xa6\x2d\xa3\x11\xa8\xb5\x04\xbc\x01\x4c\x6e\x40\x4d\x80\x57\x61\x40\x2b\xb5\x87\xd8\xab\xba\x7f\xea\xe6\x2f\xbf\x93\x47\x54\x84\xb7\xf8\xc2\x43\xd9\x81\x6d\xd5\x8e\xe3\xfd\x45\x34\xc6\xfd\x5c\x8d\xe1\x78\x5f\x78\x33\xf3\xea\x7a\x6e\xf2\xee\x43\x3f\xbe\xe5\xb7\x6a\xfe\x96\xdd\x82\xb5\xe7\xd6\xbc\xbe\x58\xc7\xb2\x1f\x18\x3a\x23\xf2\x77\x54\xf7\xdc\x21\xde\xd1\x40\xc7\xff\x13\xd9\xb5\x4d\x37\xe8\xa6\x08\x4d\x51\x10\x58\x7e\x3e\x36\x23\x22\x2a\xc2\x84\x22\x57\x45\x98\x4f\xb4\x52\x11\xbe\x56\x07\xdc\xeb\xd0\x0e\x55\x91\xd7\x56\xd0\x55\xff\x62\xc9\x7d\xe7\xc4\xee\x9a\x0f\x43\xd9\xdd\xac\x53\xfa\xff\xc4\x7b\x47\x4e\x54\x8e\x47\xfb\xae\x8a\xf0\x68\x7f\xa5\x20\xa3\x56\x56\xfa\xdd\xb6\xf5\x18\xdb\xa2\x44\x74\x2e\x1f\x88\x96\xcc\x82\x5c\xce\x67\x41\xee\x14\xe4\xce\x82\x30\xf5\x76\x35\xe3\x98\x7f\xbb\x9e\x71\x7c\xb1\xdb\xcd\x8c\xe3\xab\x9d\xe2\x8d\x5f\x7e\xda\xfc\xda\x57\xcd\xd5\x4a\xeb\x66\xe8\xb9\x1a\x53\x14\x69\x8c\x88\x3d\xc7\x4d\x2f\x44\xb9\x60\xc1\x4c\x3c\x57\xb3\xb8\x4a\xcc\x6a\xc1\xc2\x62\x32\xea\xcc\xbe\xab\xcc\xf8\xc2\xb8\x9f\x3b\xfb\xae\x32\xe3\x0b\x5b\x23\x5b\xcf\xbe\xab\xcc\xf8\xc2\x9e\x90\x3d\xcd\xbe\xab\xcc\xf8\xc2\xd8\x77\x95\x65\xe4\x38\xb2\xec\x74\x62\x20\xc4\x0b\x87\xa3\x13\x23\x89\x73\x94\xaf\x27\x5b\xef\x31\x04\x68\x84\x0b\xf1\x6a\xb0\x45\xc0\x3d\xe5\x00\xa6\x8e\x75\xcc\xab\x1a\x4d\x1b\xc3\xb4\x91\x26\xc0\x28\xe2\x66\x92\x70\x9d\x31\x92\x15\x05\xde\x12\x2b\xcf\xa2\xad\x55\xc6\xc0\x71\x75\x94\xe0\x91\xa3\x8c\x48\x9f\x0d\x82\xc8\xd9\xe8\x20\xfb\x2d\x3d\x88\x8b\x24\x70\x8f\x06\xc9\x9e\x99\x8f\xf7\xfd\x53\xd5\x55\xde\xdd\xc6\xe3\x32\xec\x6f\x3a\xe4\xd7\x8f\xb3\x64\x5b\x95\xf1\x13\xca\x97\x51\x07\xa5\xd8\xcf\xf7\xf4\xd9\xca\xce\x98\x2d\x4d\x0e\xa9\x35\xd1\x58\x97\x09\x12\x29\x92\xac\x28\xe2\x03\x22\x57\x41\xf8\xc5\xc6\xd4\x11\xed\x1b\x6b\x17\xd3\x8d\x20\xc1\xd1\x4b\x90\x6c\x05\x81\xdd\x8e\x07\x85\x23\x08\x5f\xdf\x39\x48\x46\x20\xbb\x1c\x4f\x3a\x10\x3b\x27\xbc\xd5\xfc\x17\xa5\xcd\x75\xe8\x9a\xba\x2e\x3b\x6e\x9a\x24\x22\xfd\x55\x69\xc4\xf7\xa5\x11\xdf\x97\x46\x7c\xe0\x51\x55\x5f\x3c\x4a\xe6\x23\x13\x0f\x98\xa0\xe0\x63\x92\x5f\x79\xf7\x59\x76\x96\x9f\x1c\xf6\xf6\x2f\x1b\x16\xa6\x0f\x16\xa6\x0f\x16\xa6\x0f\x16\xa6\x0f\x16\xa6\x0f\x16\xa6\x0f\x16\xa6\x0f\x16\xa6\x0f\x28\xa8\xac\xe7\x48\x6f\x0e\x50\x08\xf4\x86\x02\x3d\x89\x86\x9e\x9a\x21\xaf\xb9\xd3\x6e\x86\x88\x21\x0d\x98\xa4\x31\x55\x1f\x42\xdc\x2c\x54\x23\x43\xe7\xa8\xb7\x1e\x96\xfa\x0b\x6a\x7f\x41\x3e\x0a\xd3\x69\x77\x3b\x0e\xf7\xc5\x00\xf7\xc5\x00\x91\xe3\xaa\x33\xaf\x70\x65\xce\x25\x6d\xcd\x57\x05\xf4\x61\x97\x78\x41\x63\xe0\xef\xe8\x5c\x63\xb0\xa8\x3c\x08\xb0\x80\x01\xb5\xe2\xeb\x54\xc2\x14\x61\x7a\xeb\x87\xf2\x22\xe8\x7f\x01\x00\x00\xff\xff\x1d\x32\xff\xb6\x46\x0d\x00\x00")
-
-func smcTsvBytes() ([]byte, error) {
- return bindataRead(
- _smcTsv,
- "smc.tsv",
- )
-}
-
-func smcTsv() (*asset, error) {
- bytes, err := smcTsvBytes()
- if err != nil {
- return nil, err
- }
-
- info := bindataFileInfo{name: "smc.tsv", size: 3398, mode: os.FileMode(420), modTime: time.Unix(1612389012, 0)}
- a := &asset{bytes: bytes, info: info}
- return a, nil
-}
-
-// Asset loads and returns the asset for the given name.
-// It returns an error if the asset could not be found or
-// could not be loaded.
-func Asset(name string) ([]byte, error) {
- cannonicalName := strings.Replace(name, "\\", "/", -1)
- if f, ok := _bindata[cannonicalName]; ok {
- a, err := f()
- if err != nil {
- return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err)
- }
- return a.bytes, nil
- }
- return nil, fmt.Errorf("Asset %s not found", name)
-}
-
-// MustAsset is like Asset but panics when Asset would return an error.
-// It simplifies safe initialization of global variables.
-func MustAsset(name string) []byte {
- a, err := Asset(name)
- if err != nil {
- panic("asset: Asset(" + name + "): " + err.Error())
- }
-
- return a
-}
-
-// AssetInfo loads and returns the asset info for the given name.
-// It returns an error if the asset could not be found or
-// could not be loaded.
-func AssetInfo(name string) (os.FileInfo, error) {
- cannonicalName := strings.Replace(name, "\\", "/", -1)
- if f, ok := _bindata[cannonicalName]; ok {
- a, err := f()
- if err != nil {
- return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err)
- }
- return a.info, nil
- }
- return nil, fmt.Errorf("AssetInfo %s not found", name)
-}
-
-// AssetNames returns the names of the assets.
-func AssetNames() []string {
- names := make([]string, 0, len(_bindata))
- for name := range _bindata {
- names = append(names, name)
- }
- return names
-}
-
-// _bindata is a table, holding each asset generator, mapped to its name.
-var _bindata = map[string]func() (*asset, error){
- "smc.tsv": smcTsv,
-}
-
-// AssetDir returns the file names below a certain
-// directory embedded in the file by go-bindata.
-// For example if you run go-bindata on data/... and data contains the
-// following hierarchy:
-// data/
-// foo.txt
-// img/
-// a.png
-// b.png
-// then AssetDir("data") would return []string{"foo.txt", "img"}
-// AssetDir("data/img") would return []string{"a.png", "b.png"}
-// AssetDir("foo.txt") and AssetDir("notexist") would return an error
-// AssetDir("") will return []string{"data"}.
-func AssetDir(name string) ([]string, error) {
- node := _bintree
- if len(name) != 0 {
- cannonicalName := strings.Replace(name, "\\", "/", -1)
- pathList := strings.Split(cannonicalName, "/")
- for _, p := range pathList {
- node = node.Children[p]
- if node == nil {
- return nil, fmt.Errorf("Asset %s not found", name)
- }
- }
- }
- if node.Func != nil {
- return nil, fmt.Errorf("Asset %s not found", name)
- }
- rv := make([]string, 0, len(node.Children))
- for childName := range node.Children {
- rv = append(rv, childName)
- }
- return rv, nil
-}
-
-type bintree struct {
- Func func() (*asset, error)
- Children map[string]*bintree
-}
-
-var _bintree = &bintree{nil, map[string]*bintree{
- "smc.tsv": &bintree{smcTsv, map[string]*bintree{}},
-}}
-
-// RestoreAsset restores an asset under the given directory
-func RestoreAsset(dir, name string) error {
- data, err := Asset(name)
- if err != nil {
- return err
- }
- info, err := AssetInfo(name)
- if err != nil {
- return err
- }
- err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
- if err != nil {
- return err
- }
- err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
- if err != nil {
- return err
- }
- err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
- if err != nil {
- return err
- }
- return nil
-}
-
-// RestoreAssets restores an asset under the given directory recursively
-func RestoreAssets(dir, name string) error {
- children, err := AssetDir(name)
- // File
- if err != nil {
- return RestoreAsset(dir, name)
- }
- // Dir
- for _, child := range children {
- err = RestoreAssets(dir, filepath.Join(name, child))
- if err != nil {
- return err
- }
- }
- return nil
-}
-
-func _filePath(dir, name string) string {
- cannonicalName := strings.Replace(name, "\\", "/", -1)
- return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
-}
diff --git a/devices/data/smc.tsv b/devices/smc.tsv
index f6ff37b..f6ff37b 100644
--- a/devices/data/smc.tsv
+++ b/devices/smc.tsv
diff --git a/devices/temp_darwin.go b/devices/temp_darwin.go
index ecdc9f1..414e761 100644
--- a/devices/temp_darwin.go
+++ b/devices/temp_darwin.go
@@ -4,9 +4,11 @@ package devices
import (
"bytes"
+ _ "embed"
"encoding/csv"
"github.com/shirou/gopsutil/host"
"io"
+ "log"
)
// All possible thermometers
@@ -19,7 +21,7 @@ func devs() []string {
ids := loadIDs()
sensors, err := host.SensorsTemperatures()
if err != nil {
- // FIXME log an error here
+ log.Printf("error getting sensor list for temps: %s", err)
return []string{}
}
rv := make([]string, 0, len(sensors))
@@ -30,7 +32,7 @@ func devs() []string {
continue
}
if label, ok := ids[sensor.SensorKey]; ok {
- sensorMap[sensor.SensorKey] = label
+ sensorMap[sensor.SensorKey] = label
rv = append(rv, label)
}
}
@@ -46,22 +48,25 @@ func defs() []string {
return rv
}
+//go:embed "smc.tsv"
+var smcData []byte
+
// loadIDs parses the embedded smc.tsv data that maps Darwin SMC
// sensor IDs to their human-readable labels into an array and returns the
// array. The array keys are the 4-letter sensor keys; the values are the
// human labels.
func loadIDs() map[string]string {
rv := make(map[string]string)
- data, err := Asset("smc.tsv")
- parser := csv.NewReader(bytes.NewReader(data))
+ parser := csv.NewReader(bytes.NewReader(smcData))
parser.Comma = '\t'
var line []string
+ var err error
for {
if line, err = parser.Read(); err == io.EOF {
break
}
if err != nil {
- // FIXME log an error here
+ log.Printf("error parsing SMC tags for temp widget: %s", err)
break
}
// The line is malformed if len(line) != 2, but because the asset is static
diff --git a/devices/temp_darwin_test.go b/devices/temp_darwin_test.go
index 6222b57..a7389bd 100644
--- a/devices/temp_darwin_test.go
+++ b/devices/temp_darwin_test.go
@@ -3,9 +3,32 @@
package devices
import (
+ "bytes"
+ "encoding/csv"
"testing"
)
+func Test_NumCols(t *testing.T) {
+ parser := csv.NewReader(bytes.NewReader(smcData))
+ parser.Comma = '\t'
+ var line []string
+ for {
+ if line, err = parser.Read(); err == io.EOF {
+ break
+ }
+ if err != nil {
+ log.Printf("error parsing SMC tags for temp widget: %s", err)
+ break
+ }
+ // The line is malformed if len(line) != 2, but because the asset is static
+ // it makes no sense to report the error to downstream users. This must be
+ // tested at/around compile time.
+ if len(line) == 2 {
+ t.Errorf("smc CSV data malformed: expected 2 columns, got %d", len(line))
+ }
+ }
+}
+
func Test_loadIDs(t *testing.T) {
tests := []struct {
key string
diff --git a/translations/dicts/de_DE.toml b/dicts/de_DE.toml
index 9a8a933..9a8a933 100644
--- a/translations/dicts/de_DE.toml
+++ b/dicts/de_DE.toml
diff --git a/translations/dicts/en_US.toml b/dicts/en_US.toml
index 476556b..476556b 100644
--- a/translations/dicts/en_US.toml
+++ b/dicts/en_US.toml
diff --git a/translations/dicts/eo.toml b/dicts/eo.toml
index dfde1f5..dfde1f5 100644
--- a/translations/dicts/eo.toml
+++ b/dicts/eo.toml
diff --git a/translations/dicts/fr.toml b/dicts/fr.toml
index 35d724a..35d724a 100644
--- a/translations/dicts/fr.toml
+++ b/dicts/fr.toml
diff --git a/translations/dicts/ru_RU.toml b/dicts/ru_RU.toml
index 4ab933e..4ab933e 100644
--- a/translations/dicts/ru_RU.toml
+++ b/dicts/ru_RU.toml
diff --git a/translations/dicts/tt_TT.toml b/dicts/tt_TT.toml
index f83cb8f..f83cb8f 100644
--- a/translations/dicts/tt_TT.toml
+++ b/dicts/tt_TT.toml
diff --git a/translations/dicts/zh_CN.toml b/dicts/zh_CN.toml
index d9de273..d9de273 100644
--- a/translations/dicts/zh_CN.toml
+++ b/dicts/zh_CN.toml
diff --git a/go.mod b/go.mod
index a885fb0..b8bc904 100644
--- a/go.mod
+++ b/go.mod
@@ -9,7 +9,6 @@ require (
github.com/distatus/battery v0.10.0
github.com/gizak/termui/v3 v3.1.0
github.com/go-ole/go-ole v1.2.4 // indirect
- github.com/xxxserxxx/lingo v0.0.0-20210203173221-1a343cae68e0
github.com/mattn/go-runewidth v0.0.4
github.com/nsf/termbox-go v0.0.0-20200418040025-38ba6e5628f1 // indirect
github.com/onsi/ginkgo v1.14.2 // indirect
@@ -17,9 +16,11 @@ require (
github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0
github.com/shirou/gopsutil v3.20.12+incompatible
github.com/stretchr/testify v1.4.0
+ github.com/xxxserxxx/lingo/v2 v2.0.1
github.com/xxxserxxx/opflag v1.0.5
- golang.org/x/tools v0.1.0 // indirect
+ golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 // indirect
+ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
howett.net/plist v0.0.0-20200419221736-3b63eb3a43b5 // indirect
)
-go 1.14
+go 1.16
diff --git a/go.sum b/go.sum
index 11c1637..ba7423e 100644
--- a/go.sum
+++ b/go.sum
@@ -27,11 +27,9 @@ github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:x
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
-github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
-github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
@@ -64,8 +62,6 @@ github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0 h1:Xuk8ma/ibJ1
github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0/go.mod h1:7AwjWCpdPhkSmNAgUv5C7EJ4AbmjEB3r047r3DXWu3Y=
github.com/shirou/gopsutil v3.20.12+incompatible h1:6VEGkOXP/eP4o2Ilk8cSsX0PhOEfX6leqAnD+urrp9M=
github.com/shirou/gopsutil v3.20.12+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
-github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 h1:bUGsEnyNbVPw06Bs80sCeARAlK8lhwqGyi6UT8ymuGk=
-github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
@@ -73,25 +69,18 @@ github.com/valyala/fastrand v1.0.0 h1:LUKT9aKer2dVQNUi3waewTbKV+7H17kvWFNKs2Obdk
github.com/valyala/fastrand v1.0.0/go.mod h1:HWqCzkrkg6QXT8V2EXWvXCoow7vLwOFN002oeRzjapQ=
github.com/valyala/histogram v1.0.1 h1:FzA7n2Tz/wKRMejgu3PV1vw3