mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Merge branch 'master' into master
This commit is contained in:
commit
dfb33dba97
1
.gitignore
vendored
1
.gitignore
vendored
@ -19,3 +19,4 @@ gcal/client_secret.json
|
|||||||
.idea/
|
.idea/
|
||||||
|
|
||||||
dist/*
|
dist/*
|
||||||
|
bin/
|
||||||
|
10
.travis.yml
Normal file
10
.travis.yml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
language: go
|
||||||
|
go:
|
||||||
|
- "1.10"
|
||||||
|
sudo: false
|
||||||
|
before_install:
|
||||||
|
# Make sure travis builds work for forks
|
||||||
|
- mkdir -p $TRAVIS_BUILD_DIR $GOPATH/src/github.com/senorprogrammer
|
||||||
|
- test ! -d $GOPATH/src/github.com/senorprogrammer/wtf && mv $TRAVIS_BUILD_DIR $GOPATH/src/github.com/senorprogrammer/wtf || true
|
||||||
|
- export TRAVIS_BUILD_DIR=$HOME/gopath/src/github.com/senorprogrammer/wtf
|
||||||
|
- cd $HOME/gopath/src/github.com/senorprogrammer/wtf
|
169
Gopkg.lock
generated
Normal file
169
Gopkg.lock
generated
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||||
|
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "cloud.google.com/go"
|
||||||
|
packages = ["compute/metadata"]
|
||||||
|
revision = "0fd7230b2a7505833d5f69b75cbd6c9582401479"
|
||||||
|
version = "v0.23.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/briandowns/openweathermap"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "2adae1e5d10290d8cd435bd30296fc5e8f754862"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/gdamore/encoding"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "b23993cbb6353f0e6aa98d0ee318a34728f628b9"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/gdamore/tcell"
|
||||||
|
packages = [
|
||||||
|
".",
|
||||||
|
"terminfo"
|
||||||
|
]
|
||||||
|
revision = "061d51a604c546b48e92253cb65190d76cecf4c6"
|
||||||
|
version = "v1.0.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/go-test/deep"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "6592d9cc0a499ad2d5f574fde80a2b5c5cc3b4f5"
|
||||||
|
version = "v1.0.1"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/golang/protobuf"
|
||||||
|
packages = ["proto"]
|
||||||
|
revision = "b4deda0973fb4c70b50d226b1af49f3da59f5265"
|
||||||
|
version = "v1.1.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/google/go-github"
|
||||||
|
packages = ["github"]
|
||||||
|
revision = "2ae5df7848328c214a48cec94c7d410cf8526527"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/google/go-querystring"
|
||||||
|
packages = ["query"]
|
||||||
|
revision = "53e6ce116135b80d037921a7fdd5138cf32d7a8a"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/jessevdk/go-flags"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "c6ca198ec95c841fdb89fc0de7496fed11ab854e"
|
||||||
|
version = "v1.4.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/lucasb-eyer/go-colorful"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "345fbb3dbcdb252d9985ee899a84963c0fa24c82"
|
||||||
|
version = "v1.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/mattn/go-runewidth"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "9e777a8366cce605130a531d2cd6363d07ad7317"
|
||||||
|
version = "v0.0.2"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/olebedev/config"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "9a10d05a33a8b9e828f20491e21e8927dec35f72"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/radovskyb/watcher"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "6145e1439b9de93806925353403f91d2abbad8a5"
|
||||||
|
version = "v1.0.2"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/rivo/tview"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "71ecf1f4299c6d72b16d20da72405b7e85ac8720"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/yfronto/newrelic"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "f7fa0c6f30ac3d86360c73726cfe9dd526a63d21"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "golang.org/x/net"
|
||||||
|
packages = [
|
||||||
|
"context",
|
||||||
|
"context/ctxhttp"
|
||||||
|
]
|
||||||
|
revision = "1e491301e022f8f977054da4c2d852decd59571f"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "golang.org/x/oauth2"
|
||||||
|
packages = [
|
||||||
|
".",
|
||||||
|
"google",
|
||||||
|
"internal",
|
||||||
|
"jws",
|
||||||
|
"jwt"
|
||||||
|
]
|
||||||
|
revision = "1e0a3fa8ba9a5c9eb35c271780101fdaf1b205d7"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "golang.org/x/text"
|
||||||
|
packages = [
|
||||||
|
"encoding",
|
||||||
|
"encoding/internal/identifier",
|
||||||
|
"internal/gen",
|
||||||
|
"transform",
|
||||||
|
"unicode/cldr"
|
||||||
|
]
|
||||||
|
revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0"
|
||||||
|
version = "v0.3.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "google.golang.org/api"
|
||||||
|
packages = [
|
||||||
|
"calendar/v3",
|
||||||
|
"gensupport",
|
||||||
|
"googleapi",
|
||||||
|
"googleapi/internal/uritemplates"
|
||||||
|
]
|
||||||
|
revision = "00e3bb8d04691e25ee2fccf98c866bcb7925c3ec"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "google.golang.org/appengine"
|
||||||
|
packages = [
|
||||||
|
".",
|
||||||
|
"internal",
|
||||||
|
"internal/app_identity",
|
||||||
|
"internal/base",
|
||||||
|
"internal/datastore",
|
||||||
|
"internal/log",
|
||||||
|
"internal/modules",
|
||||||
|
"internal/remote_api",
|
||||||
|
"internal/urlfetch",
|
||||||
|
"urlfetch"
|
||||||
|
]
|
||||||
|
revision = "150dc57a1b433e64154302bdc40b6bb8aefa313a"
|
||||||
|
version = "v1.0.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "gopkg.in/yaml.v2"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "5420a8b6744d3b0345ab293f6fcba19c978f1183"
|
||||||
|
version = "v2.2.1"
|
||||||
|
|
||||||
|
[solve-meta]
|
||||||
|
analyzer-name = "dep"
|
||||||
|
analyzer-version = 1
|
||||||
|
inputs-digest = "b0e632406212933c5f4d7652db7aa06e63f4ed94d38ceb823e5c51b865c20be0"
|
||||||
|
solver-name = "gps-cdcl"
|
||||||
|
solver-version = 1
|
78
Gopkg.toml
Normal file
78
Gopkg.toml
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
# Gopkg.toml example
|
||||||
|
#
|
||||||
|
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
|
||||||
|
# for detailed Gopkg.toml documentation.
|
||||||
|
#
|
||||||
|
# required = ["github.com/user/thing/cmd/thing"]
|
||||||
|
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
|
||||||
|
#
|
||||||
|
# [[constraint]]
|
||||||
|
# name = "github.com/user/project"
|
||||||
|
# version = "1.0.0"
|
||||||
|
#
|
||||||
|
# [[constraint]]
|
||||||
|
# name = "github.com/user/project2"
|
||||||
|
# branch = "dev"
|
||||||
|
# source = "github.com/myfork/project2"
|
||||||
|
#
|
||||||
|
# [[override]]
|
||||||
|
# name = "github.com/x/y"
|
||||||
|
# version = "2.4.0"
|
||||||
|
#
|
||||||
|
# [prune]
|
||||||
|
# non-go = false
|
||||||
|
# go-tests = true
|
||||||
|
# unused-packages = true
|
||||||
|
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/briandowns/openweathermap"
|
||||||
|
branch = "master"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/gdamore/tcell"
|
||||||
|
version = "1.0.0"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/go-test/deep"
|
||||||
|
version = "1.0.1"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/google/go-github"
|
||||||
|
branch = "master"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/jessevdk/go-flags"
|
||||||
|
version = "1.4.0"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/olebedev/config"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/radovskyb/watcher"
|
||||||
|
version = "1.0.2"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/rivo/tview"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/yfronto/newrelic"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
branch = "master"
|
||||||
|
name = "golang.org/x/oauth2"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
branch = "master"
|
||||||
|
name = "google.golang.org/api"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "gopkg.in/yaml.v2"
|
||||||
|
version = "2.2.1"
|
||||||
|
|
||||||
|
[prune]
|
||||||
|
go-tests = true
|
||||||
|
unused-packages = true
|
8
Makefile
8
Makefile
@ -2,13 +2,13 @@ BRANCH := `git rev-parse --abbrev-ref HEAD`
|
|||||||
|
|
||||||
.PHONY: dependencies install run
|
.PHONY: dependencies install run
|
||||||
|
|
||||||
dependencies:
|
build:
|
||||||
go get -v ./...
|
go build -o bin/wtf
|
||||||
|
|
||||||
install:
|
install:
|
||||||
which wtf | xargs rm || true
|
which wtf | xargs rm || true
|
||||||
go install -ldflags="-X main.version=$(shell git describe --always --abbrev=6)_$(BRANCH) -X main.date=$(shell date +%FT%T%z)"
|
go install -ldflags="-X main.version=$(shell git describe --always --abbrev=6)_$(BRANCH) -X main.date=$(shell date +%FT%T%z)"
|
||||||
which wtf
|
which wtf
|
||||||
|
|
||||||
run:
|
run: build
|
||||||
wtf
|
bin/wtf
|
||||||
|
11
README.md
11
README.md
@ -1,3 +1,8 @@
|
|||||||
|
<p align="right">
|
||||||
|
|
||||||
|
<img src="https://travis-ci.com/senorprogrammer/wtf.svg?branch=master" />
|
||||||
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="./docs/img/wtf.jpg?raw=true" title="WTF" width="852" height="240" />
|
<img src="./docs/img/wtf.jpg?raw=true" title="WTF" width="852" height="240" />
|
||||||
</p>
|
</p>
|
||||||
@ -13,8 +18,7 @@ displaying infrequently-needed, but very important, daily data.
|
|||||||
|
|
||||||
### Installation from Source
|
### Installation from Source
|
||||||
|
|
||||||
*Note:* This has only been tested to build against Go 1.9.2. It won't
|
**Note:** WTF is _only_ compatible with Go versions **1.9.2** or later. It currently _does not_ compile with `gccgo`.
|
||||||
work with Go versions < 1.7, and only _may_ work on other versions.
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
go get -u github.com/senorprogrammer/wtf
|
go get -u github.com/senorprogrammer/wtf
|
||||||
@ -27,7 +31,7 @@ Or [download the latest binary](https://github.com/senorprogrammer/wtf/releases)
|
|||||||
|
|
||||||
## Support
|
## Support
|
||||||
|
|
||||||
Chat on Gitter:
|
Chat on Gitter
|
||||||
[](https://gitter.im/wtfutil/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
[](https://gitter.im/wtfutil/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
@ -95,3 +99,4 @@ Many thanks to all these developers.
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="./docs/img/dude_wtf.png?raw=true" title="Dude WTF" width="251" height="201" />
|
<img src="./docs/img/dude_wtf.png?raw=true" title="Dude WTF" width="251" height="201" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
---
|
---
|
||||||
title: "Github"
|
title: "GitHub"
|
||||||
date: 2018-05-09T19:20:20-07:00
|
date: 2018-05-09T19:20:20-07:00
|
||||||
draft: false
|
draft: false
|
||||||
---
|
---
|
||||||
|
|
||||||
Displays information about git repositories hosted on Github: open
|
Displays information about your git repositories hosted on Github:
|
||||||
review requests, and open pull requests.
|
|
||||||
|
|
||||||
<img src="/imgs/modules/github.png" width="640" height="384" alt="github screenshot" />
|
|
||||||
|
|
||||||
#### Open Review Requests
|
#### Open Review Requests
|
||||||
|
|
||||||
@ -17,6 +15,8 @@ All open code review requests assigned to you.
|
|||||||
|
|
||||||
All open pull requests created by you.
|
All open pull requests created by you.
|
||||||
|
|
||||||
|
<img src="/imgs/modules/github.png" width="640" height="384" alt="github screenshot" />
|
||||||
|
|
||||||
## Source Code
|
## Source Code
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
@ -6,6 +6,8 @@ draft: false
|
|||||||
|
|
||||||
Displays your current IP address information, from ipinfo.io.
|
Displays your current IP address information, from ipinfo.io.
|
||||||
|
|
||||||
|
**Note:** IPInfo.io has a free-plan rate limit of 1000 requests per day.
|
||||||
|
|
||||||
<img src="/imgs/modules/ipinfo.png" width="320" height="199" alt="ipinfo screenshot" />
|
<img src="/imgs/modules/ipinfo.png" width="320" height="199" alt="ipinfo screenshot" />
|
||||||
|
|
||||||
## Source Code
|
## Source Code
|
||||||
@ -35,7 +37,7 @@ ipinfo:
|
|||||||
left: 2
|
left: 2
|
||||||
height: 1
|
height: 1
|
||||||
width: 1
|
width: 1
|
||||||
refreshInterval: 15
|
refreshInterval: 150
|
||||||
```
|
```
|
||||||
|
|
||||||
### Attributes
|
### Attributes
|
||||||
|
@ -38,6 +38,7 @@ None.
|
|||||||
width: 1
|
width: 1
|
||||||
refreshInterval: 300
|
refreshInterval: 300
|
||||||
unit: "c"
|
unit: "c"
|
||||||
|
view: 0
|
||||||
```
|
```
|
||||||
|
|
||||||
### Attributes
|
### Attributes
|
||||||
@ -62,3 +63,7 @@ Values: A positive integer, `0..n`.
|
|||||||
_Optional_. It will use metric if you are out of US and imperial for US.<br />
|
_Optional_. It will use metric if you are out of US and imperial for US.<br />
|
||||||
The temperature scale in which to display temperature values. <br />
|
The temperature scale in which to display temperature values. <br />
|
||||||
Values: `F` for Fahrenheit, `C` for Celcius.
|
Values: `F` for Fahrenheit, `C` for Celcius.
|
||||||
|
|
||||||
|
`view` <br />
|
||||||
|
_Optional_ Wttr.in view configuration. <br />
|
||||||
|
Values: See `curl wttr.in/:help` for more details.
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package bamboohr
|
package bamboohr
|
||||||
|
|
||||||
import ()
|
|
||||||
|
|
||||||
type Calendar struct {
|
type Calendar struct {
|
||||||
Items []Item `xml:"item"`
|
Items []Item `xml:"item"`
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package bamboohr
|
package bamboohr
|
||||||
|
|
||||||
import ()
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note: this currently implements the minimum number of fields to fulfill the Away functionality.
|
* Note: this currently implements the minimum number of fields to fulfill the Away functionality.
|
||||||
* Undoubtedly there are more fields than this to an employee
|
* Undoubtedly there are more fields than this to an employee
|
||||||
|
@ -28,7 +28,7 @@ type TextColors struct {
|
|||||||
|
|
||||||
var ok = true
|
var ok = true
|
||||||
var errorText = ""
|
var errorText = ""
|
||||||
var started = false
|
|
||||||
var baseURL = "https://bittrex.com/api/v1.1/public/getmarketsummary"
|
var baseURL = "https://bittrex.com/api/v1.1/public/getmarketsummary"
|
||||||
|
|
||||||
// Widget define wtf widget to register widget later
|
// Widget define wtf widget to register widget later
|
||||||
@ -40,13 +40,11 @@ type Widget struct {
|
|||||||
|
|
||||||
// NewWidget Make new instance of widget
|
// NewWidget Make new instance of widget
|
||||||
func NewWidget() *Widget {
|
func NewWidget() *Widget {
|
||||||
|
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget(" Bittrex ", "bittrex", false),
|
TextWidget: wtf.NewTextWidget(" Bittrex ", "bittrex", false),
|
||||||
summaryList: summaryList{},
|
summaryList: summaryList{},
|
||||||
}
|
}
|
||||||
|
|
||||||
started = false
|
|
||||||
ok = true
|
ok = true
|
||||||
errorText = ""
|
errorText = ""
|
||||||
|
|
||||||
@ -106,20 +104,9 @@ func (widget *Widget) Refresh() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if started == false {
|
|
||||||
go func() {
|
|
||||||
for {
|
|
||||||
widget.updateSummary()
|
widget.updateSummary()
|
||||||
time.Sleep(time.Second * time.Duration(widget.RefreshInterval()))
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
started = true
|
|
||||||
}
|
|
||||||
|
|
||||||
widget.UpdateRefreshedAt()
|
widget.UpdateRefreshedAt()
|
||||||
|
|
||||||
widget.display()
|
widget.display()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
@ -13,7 +13,6 @@ import (
|
|||||||
// Config is a pointer to the global config object
|
// Config is a pointer to the global config object
|
||||||
var Config *config.Config
|
var Config *config.Config
|
||||||
|
|
||||||
var started = false
|
|
||||||
var baseURL = "https://min-api.cryptocompare.com/data/price"
|
var baseURL = "https://min-api.cryptocompare.com/data/price"
|
||||||
var ok = true
|
var ok = true
|
||||||
|
|
||||||
@ -26,7 +25,6 @@ type Widget struct {
|
|||||||
|
|
||||||
// NewWidget Make new instance of widget
|
// NewWidget Make new instance of widget
|
||||||
func NewWidget() *Widget {
|
func NewWidget() *Widget {
|
||||||
started = false
|
|
||||||
widget := Widget{
|
widget := Widget{
|
||||||
TextWidget: wtf.NewTextWidget(" CryptoLive ", "cryptolive", false),
|
TextWidget: wtf.NewTextWidget(" CryptoLive ", "cryptolive", false),
|
||||||
}
|
}
|
||||||
@ -36,19 +34,6 @@ func NewWidget() *Widget {
|
|||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
func (widget *Widget) setList() {
|
|
||||||
currenciesMap, _ := Config.Map("wtf.mods.cryptolive.currencies")
|
|
||||||
|
|
||||||
widget.list = &list{}
|
|
||||||
|
|
||||||
for currency := range currenciesMap {
|
|
||||||
displayName, _ := Config.String("wtf.mods.cryptolive.currencies." + currency + ".displayName")
|
|
||||||
toList := getToList(currency)
|
|
||||||
widget.list.addItem(currency, displayName, toList)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------- Exported Functions -------------------- */
|
/* -------------------- Exported Functions -------------------- */
|
||||||
|
|
||||||
// Refresh & update after interval time
|
// Refresh & update after interval time
|
||||||
@ -57,21 +42,8 @@ func (widget *Widget) Refresh() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if started == false {
|
|
||||||
// this code should run once
|
|
||||||
go func() {
|
|
||||||
for {
|
|
||||||
widget.updateCurrencies()
|
widget.updateCurrencies()
|
||||||
time.Sleep(time.Duration(widget.RefreshInterval()) * time.Second)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
started = true
|
|
||||||
|
|
||||||
widget.UpdateRefreshedAt()
|
widget.UpdateRefreshedAt()
|
||||||
widget.View.Clear()
|
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
widget.View.SetText(
|
widget.View.SetText(
|
||||||
@ -79,12 +51,13 @@ func (widget *Widget) Refresh() {
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
display(widget)
|
|
||||||
|
widget.display()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
|
||||||
func display(widget *Widget) {
|
func (widget *Widget) display() {
|
||||||
str := ""
|
str := ""
|
||||||
var (
|
var (
|
||||||
fromNameColor = Config.UString("wtf.mods.cryptolive.colors.from.name", "coral")
|
fromNameColor = Config.UString("wtf.mods.cryptolive.colors.from.name", "coral")
|
||||||
@ -118,6 +91,18 @@ func getToList(fromName string) []*toCurrency {
|
|||||||
return toList
|
return toList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (widget *Widget) setList() {
|
||||||
|
currenciesMap, _ := Config.Map("wtf.mods.cryptolive.currencies")
|
||||||
|
|
||||||
|
widget.list = &list{}
|
||||||
|
|
||||||
|
for currency := range currenciesMap {
|
||||||
|
displayName, _ := Config.String("wtf.mods.cryptolive.currencies." + currency + ".displayName")
|
||||||
|
toList := getToList(currency)
|
||||||
|
widget.list.addItem(currency, displayName, toList)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (widget *Widget) updateCurrencies() {
|
func (widget *Widget) updateCurrencies() {
|
||||||
defer func() {
|
defer func() {
|
||||||
recover()
|
recover()
|
||||||
@ -149,7 +134,7 @@ func (widget *Widget) updateCurrencies() {
|
|||||||
setPrices(&jsonResponse, fromCurrency)
|
setPrices(&jsonResponse, fromCurrency)
|
||||||
}
|
}
|
||||||
|
|
||||||
display(widget)
|
widget.display()
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeRequest(currency *fromCurrency) *http.Request {
|
func makeRequest(currency *fromCurrency) *http.Request {
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -71,7 +71,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -57,7 +57,7 @@ position Defines where in the grid this module&rsquo;s widget will be displa
|
|||||||
Displays weather information as ASCII art from Wttr.in.
|
Displays weather information as ASCII art from Wttr.in.
|
||||||
Source Code wtf/prettyweather/ Required ENV Variables None.
|
Source Code wtf/prettyweather/ Required ENV Variables None.
|
||||||
Keyboard Commands None.
|
Keyboard Commands None.
|
||||||
Configuration prettyweather:enabled:truecity:&#34;tehran&#34;position:top:3left:5height:1width:1refreshInterval:300unit:&#34;c&#34; Attributes city Optional. It will grab the current location from your IP address if omitted.
|
Configuration prettyweather:enabled:truecity:&#34;tehran&#34;position:top:3left:5height:1width:1refreshInterval:300unit:&#34;c&#34;view:0 Attributes city Optional. It will grab the current location from your IP address if omitted.
|
||||||
Values: The name of any city supported by Wttr.in.
|
Values: The name of any city supported by Wttr.in.
|
||||||
enabled Determines whether or not this module is executed and if its data displayed onscreen. Values: true, false.
|
enabled Determines whether or not this module is executed and if its data displayed onscreen. Values: true, false.
|
||||||
position Defines where in the grid this module&rsquo;s widget will be displayed.</description>
|
position Defines where in the grid this module&rsquo;s widget will be displayed.</description>
|
||||||
@ -70,12 +70,12 @@ position Defines where in the grid this module&rsquo;s widget will be displa
|
|||||||
|
|
||||||
<guid>https://wtfutil.com/posts/modules/ipinfo/</guid>
|
<guid>https://wtfutil.com/posts/modules/ipinfo/</guid>
|
||||||
<description>Displays your current IP address information, from ipinfo.io.
|
<description>Displays your current IP address information, from ipinfo.io.
|
||||||
|
Note: IPInfo.io has a free-plan rate limit of 1000 requests per day.
|
||||||
Source Code wtf/ipinfo/ Required ENV Variables None.
|
Source Code wtf/ipinfo/ Required ENV Variables None.
|
||||||
Keyboard Commands None.
|
Keyboard Commands None.
|
||||||
Configuration ipinfo:colors:name:redvalue:whiteenabled:trueposition:top:1left:2height:1width:1refreshInterval:15 Attributes colors.name The default colour for the row names. Values: Any X11 color name.
|
Configuration ipinfo:colors:name:redvalue:whiteenabled:trueposition:top:1left:2height:1width:1refreshInterval:150 Attributes colors.name The default colour for the row names. Values: Any X11 color name.
|
||||||
colors.value The default colour for the row values. Values: Any X11 color name.
|
colors.value The default colour for the row values. Values: Any X11 color name.
|
||||||
enabled Determines whether or not this module is executed and if its data displayed onscreen. Values: true, false.
|
enabled Determines whether or not this module is executed and if its data displayed onscreen.</description>
|
||||||
position Defines where in the grid this module&rsquo;s widget will be displayed.</description>
|
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
@ -195,12 +195,12 @@ Keyboard Commands None.</description>
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<title>Github</title>
|
<title>GitHub</title>
|
||||||
<link>https://wtfutil.com/posts/modules/github/</link>
|
<link>https://wtfutil.com/posts/modules/github/</link>
|
||||||
<pubDate>Wed, 09 May 2018 19:20:20 -0700</pubDate>
|
<pubDate>Wed, 09 May 2018 19:20:20 -0700</pubDate>
|
||||||
|
|
||||||
<guid>https://wtfutil.com/posts/modules/github/</guid>
|
<guid>https://wtfutil.com/posts/modules/github/</guid>
|
||||||
<description>Displays information about git repositories hosted on Github: open review requests, and open pull requests.
|
<description>Displays information about your git repositories hosted on Github:
|
||||||
Open Review Requests All open code review requests assigned to you.
|
Open Review Requests All open code review requests assigned to you.
|
||||||
Open Pull Requests All open pull requests created by you.
|
Open Pull Requests All open pull requests created by you.
|
||||||
Source Code wtf/github/ Required ENV Variables Key: WTF_GITHUB_TOKEN Action: Your Github API token.
|
Source Code wtf/github/ Required ENV Variables Key: WTF_GITHUB_TOKEN Action: Your Github API token.
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -71,7 +71,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
@ -191,7 +191,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</li><li>
|
</li><li>
|
||||||
<span>
|
<span>
|
||||||
<a href="https://wtfutil.com/posts/modules/github/">Github</a>
|
<a href="https://wtfutil.com/posts/modules/github/">GitHub</a>
|
||||||
|
|
||||||
<time class="pull-right post-list">May 09, 2018</time>
|
<time class="pull-right post-list">May 09, 2018</time>
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ position Defines where in the grid this module&rsquo;s widget will be displa
|
|||||||
Displays weather information as ASCII art from Wttr.in.
|
Displays weather information as ASCII art from Wttr.in.
|
||||||
Source Code wtf/prettyweather/ Required ENV Variables None.
|
Source Code wtf/prettyweather/ Required ENV Variables None.
|
||||||
Keyboard Commands None.
|
Keyboard Commands None.
|
||||||
Configuration prettyweather:enabled:truecity:&#34;tehran&#34;position:top:3left:5height:1width:1refreshInterval:300unit:&#34;c&#34; Attributes city Optional. It will grab the current location from your IP address if omitted.
|
Configuration prettyweather:enabled:truecity:&#34;tehran&#34;position:top:3left:5height:1width:1refreshInterval:300unit:&#34;c&#34;view:0 Attributes city Optional. It will grab the current location from your IP address if omitted.
|
||||||
Values: The name of any city supported by Wttr.in.
|
Values: The name of any city supported by Wttr.in.
|
||||||
enabled Determines whether or not this module is executed and if its data displayed onscreen. Values: true, false.
|
enabled Determines whether or not this module is executed and if its data displayed onscreen. Values: true, false.
|
||||||
position Defines where in the grid this module&rsquo;s widget will be displayed.</description>
|
position Defines where in the grid this module&rsquo;s widget will be displayed.</description>
|
||||||
@ -70,12 +70,12 @@ position Defines where in the grid this module&rsquo;s widget will be displa
|
|||||||
|
|
||||||
<guid>https://wtfutil.com/posts/modules/ipinfo/</guid>
|
<guid>https://wtfutil.com/posts/modules/ipinfo/</guid>
|
||||||
<description>Displays your current IP address information, from ipinfo.io.
|
<description>Displays your current IP address information, from ipinfo.io.
|
||||||
|
Note: IPInfo.io has a free-plan rate limit of 1000 requests per day.
|
||||||
Source Code wtf/ipinfo/ Required ENV Variables None.
|
Source Code wtf/ipinfo/ Required ENV Variables None.
|
||||||
Keyboard Commands None.
|
Keyboard Commands None.
|
||||||
Configuration ipinfo:colors:name:redvalue:whiteenabled:trueposition:top:1left:2height:1width:1refreshInterval:15 Attributes colors.name The default colour for the row names. Values: Any X11 color name.
|
Configuration ipinfo:colors:name:redvalue:whiteenabled:trueposition:top:1left:2height:1width:1refreshInterval:150 Attributes colors.name The default colour for the row names. Values: Any X11 color name.
|
||||||
colors.value The default colour for the row values. Values: Any X11 color name.
|
colors.value The default colour for the row values. Values: Any X11 color name.
|
||||||
enabled Determines whether or not this module is executed and if its data displayed onscreen. Values: true, false.
|
enabled Determines whether or not this module is executed and if its data displayed onscreen.</description>
|
||||||
position Defines where in the grid this module&rsquo;s widget will be displayed.</description>
|
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
@ -195,12 +195,12 @@ Keyboard Commands None.</description>
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<title>Github</title>
|
<title>GitHub</title>
|
||||||
<link>https://wtfutil.com/posts/modules/github/</link>
|
<link>https://wtfutil.com/posts/modules/github/</link>
|
||||||
<pubDate>Wed, 09 May 2018 19:20:20 -0700</pubDate>
|
<pubDate>Wed, 09 May 2018 19:20:20 -0700</pubDate>
|
||||||
|
|
||||||
<guid>https://wtfutil.com/posts/modules/github/</guid>
|
<guid>https://wtfutil.com/posts/modules/github/</guid>
|
||||||
<description>Displays information about git repositories hosted on Github: open review requests, and open pull requests.
|
<description>Displays information about your git repositories hosted on Github:
|
||||||
Open Review Requests All open code review requests assigned to you.
|
Open Review Requests All open code review requests assigned to you.
|
||||||
Open Pull Requests All open pull requests created by you.
|
Open Pull Requests All open pull requests created by you.
|
||||||
Source Code wtf/github/ Required ENV Variables Key: WTF_GITHUB_TOKEN Action: Your Github API token.
|
Source Code wtf/github/ Required ENV Variables Key: WTF_GITHUB_TOKEN Action: Your Github API token.
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
<meta name="generator" content="Hugo 0.38.2" />
|
<meta name="generator" content="Hugo 0.38.2" />
|
||||||
|
|
||||||
<title>Github | WTF - A Terminal Dashboard</title>
|
<title>GitHub | WTF - A Terminal Dashboard</title>
|
||||||
<meta content="Github - WTF - A Terminal Dashboard" property="og:title">
|
<meta content="GitHub - WTF - A Terminal Dashboard" property="og:title">
|
||||||
<meta content=" - " property="og:description">
|
<meta content=" - " property="og:description">
|
||||||
<!-- CSS -->
|
<!-- CSS -->
|
||||||
<link rel="stylesheet" href="//cdn.rawgit.com/milligram/milligram/master/dist/milligram.min.css">
|
<link rel="stylesheet" href="//cdn.rawgit.com/milligram/milligram/master/dist/milligram.min.css">
|
||||||
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
@ -95,7 +95,7 @@
|
|||||||
|
|
||||||
<div class="content container">
|
<div class="content container">
|
||||||
<div class="post">
|
<div class="post">
|
||||||
<h1>Github</h1>
|
<h1>GitHub</h1>
|
||||||
|
|
||||||
<div class="col-sm-12 col-md-12">
|
<div class="col-sm-12 col-md-12">
|
||||||
<span class="text-left post-date meta">
|
<span class="text-left post-date meta">
|
||||||
@ -113,10 +113,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<p>Displays information about git repositories hosted on Github: open
|
<p>Displays information about your git repositories hosted on Github:</p>
|
||||||
review requests, and open pull requests.</p>
|
|
||||||
|
|
||||||
<p><img src="/imgs/modules/github.png" width="640" height="384" alt="github screenshot" /></p>
|
|
||||||
|
|
||||||
<h4 id="open-review-requests">Open Review Requests</h4>
|
<h4 id="open-review-requests">Open Review Requests</h4>
|
||||||
|
|
||||||
@ -126,6 +123,8 @@ review requests, and open pull requests.</p>
|
|||||||
|
|
||||||
<p>All open pull requests created by you.</p>
|
<p>All open pull requests created by you.</p>
|
||||||
|
|
||||||
|
<p><img src="/imgs/modules/github.png" width="640" height="384" alt="github screenshot" /></p>
|
||||||
|
|
||||||
<h2 id="source-code">Source Code</h2>
|
<h2 id="source-code">Source Code</h2>
|
||||||
<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash">wtf/github/</code></pre></div>
|
<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash">wtf/github/</code></pre></div>
|
||||||
<h2 id="required-env-variables">Required ENV Variables</h2>
|
<h2 id="required-env-variables">Required ENV Variables</h2>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
@ -115,6 +115,8 @@
|
|||||||
|
|
||||||
<p>Displays your current IP address information, from ipinfo.io.</p>
|
<p>Displays your current IP address information, from ipinfo.io.</p>
|
||||||
|
|
||||||
|
<p><strong>Note:</strong> IPInfo.io has a free-plan rate limit of 1000 requests per day.</p>
|
||||||
|
|
||||||
<p><img src="/imgs/modules/ipinfo.png" width="320" height="199" alt="ipinfo screenshot" /></p>
|
<p><img src="/imgs/modules/ipinfo.png" width="320" height="199" alt="ipinfo screenshot" /></p>
|
||||||
|
|
||||||
<h2 id="source-code">Source Code</h2>
|
<h2 id="source-code">Source Code</h2>
|
||||||
@ -138,7 +140,7 @@
|
|||||||
</span><span class="w"> </span>left<span class="p">:</span><span class="w"> </span><span class="m">2</span><span class="w">
|
</span><span class="w"> </span>left<span class="p">:</span><span class="w"> </span><span class="m">2</span><span class="w">
|
||||||
</span><span class="w"> </span>height<span class="p">:</span><span class="w"> </span><span class="m">1</span><span class="w">
|
</span><span class="w"> </span>height<span class="p">:</span><span class="w"> </span><span class="m">1</span><span class="w">
|
||||||
</span><span class="w"> </span>width<span class="p">:</span><span class="w"> </span><span class="m">1</span><span class="w">
|
</span><span class="w"> </span>width<span class="p">:</span><span class="w"> </span><span class="m">1</span><span class="w">
|
||||||
</span><span class="w"> </span>refreshInterval<span class="p">:</span><span class="w"> </span><span class="m">15</span></code></pre></div>
|
</span><span class="w"> </span>refreshInterval<span class="p">:</span><span class="w"> </span><span class="m">150</span></code></pre></div>
|
||||||
<h3 id="attributes">Attributes</h3>
|
<h3 id="attributes">Attributes</h3>
|
||||||
|
|
||||||
<p><code>colors.name</code> <br />
|
<p><code>colors.name</code> <br />
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
@ -140,7 +140,8 @@
|
|||||||
</span><span class="w"> </span>height<span class="p">:</span><span class="w"> </span><span class="m">1</span><span class="w">
|
</span><span class="w"> </span>height<span class="p">:</span><span class="w"> </span><span class="m">1</span><span class="w">
|
||||||
</span><span class="w"> </span>width<span class="p">:</span><span class="w"> </span><span class="m">1</span><span class="w">
|
</span><span class="w"> </span>width<span class="p">:</span><span class="w"> </span><span class="m">1</span><span class="w">
|
||||||
</span><span class="w"> </span>refreshInterval<span class="p">:</span><span class="w"> </span><span class="m">300</span><span class="w">
|
</span><span class="w"> </span>refreshInterval<span class="p">:</span><span class="w"> </span><span class="m">300</span><span class="w">
|
||||||
</span><span class="w"> </span>unit<span class="p">:</span><span class="w"> </span><span class="s2">"c"</span></code></pre></div>
|
</span><span class="w"> </span>unit<span class="p">:</span><span class="w"> </span><span class="s2">"c"</span><span class="w">
|
||||||
|
</span><span class="w"> </span>view<span class="p">:</span><span class="w"> </span><span class="m">0</span></code></pre></div>
|
||||||
<h3 id="attributes">Attributes</h3>
|
<h3 id="attributes">Attributes</h3>
|
||||||
|
|
||||||
<p><code>city</code> <br />
|
<p><code>city</code> <br />
|
||||||
@ -164,6 +165,10 @@ Values: A positive integer, <code>0..n</code>.</p>
|
|||||||
The temperature scale in which to display temperature values. <br />
|
The temperature scale in which to display temperature values. <br />
|
||||||
Values: <code>F</code> for Fahrenheit, <code>C</code> for Celcius.</p>
|
Values: <code>F</code> for Fahrenheit, <code>C</code> for Celcius.</p>
|
||||||
|
|
||||||
|
<p><code>view</code> <br />
|
||||||
|
<em>Optional</em> Wttr.in view configuration. <br />
|
||||||
|
Values: See <code>curl wttr.in/:help</code> for more details.</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -71,7 +71,7 @@
|
|||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cryptocurrencies/cryptolive/">CryptoLive</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/cmdrunner/">CmdRunner</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/git/">Git</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">Github</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/github/">GitHub</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/gcal/">Google Calendar</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/ipinfo/">IPInfo</a></li>
|
||||||
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
<li class="sidebar-list-item-2"><a href="/posts/modules/jira/">Jira</a></li>
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package jira
|
package jira
|
||||||
|
|
||||||
import (
|
|
||||||
)
|
|
||||||
|
|
||||||
type Issue struct {
|
type Issue struct {
|
||||||
Expand string `json:"expand"`
|
Expand string `json:"expand"`
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package jira
|
package jira
|
||||||
|
|
||||||
import ()
|
|
||||||
|
|
||||||
type SearchResult struct {
|
type SearchResult struct {
|
||||||
StartAt int `json:"startAt"`
|
StartAt int `json:"startAt"`
|
||||||
MaxResults int `json:"maxResults"`
|
MaxResults int `json:"maxResults"`
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
// +build !linux
|
||||||
|
|
||||||
package power
|
package power
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
112
power/battery_linux.go
Normal file
112
power/battery_linux.go
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
// +build linux
|
||||||
|
|
||||||
|
package power
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os/exec"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
|
)
|
||||||
|
|
||||||
|
var batteryState string
|
||||||
|
|
||||||
|
type Battery struct {
|
||||||
|
args []string
|
||||||
|
cmd string
|
||||||
|
result string
|
||||||
|
|
||||||
|
Charge string
|
||||||
|
Remaining string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewBattery() *Battery {
|
||||||
|
return &Battery{}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------- Exported Functions -------------------- */
|
||||||
|
|
||||||
|
func (battery *Battery) Refresh() {
|
||||||
|
data := battery.execute()
|
||||||
|
battery.result = battery.parse(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (battery *Battery) String() string {
|
||||||
|
return battery.result
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
|
||||||
|
func (battery *Battery) execute() string {
|
||||||
|
cmd := exec.Command("upower", "-e")
|
||||||
|
lines := strings.Split(wtf.ExecuteCommand(cmd), "\n")
|
||||||
|
var target string
|
||||||
|
for _, l := range lines {
|
||||||
|
if strings.Contains(l, "/battery") {
|
||||||
|
target = l
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cmd = exec.Command("upower", "-i", target)
|
||||||
|
return wtf.ExecuteCommand(cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (battery *Battery) parse(data string) string {
|
||||||
|
lines := strings.Split(data, "\n")
|
||||||
|
if len(lines) < 2 {
|
||||||
|
return "unknown"
|
||||||
|
}
|
||||||
|
table := make(map[string]string)
|
||||||
|
for _, line := range lines {
|
||||||
|
parts := strings.Split(line, ":")
|
||||||
|
if len(parts) < 2 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
table[strings.TrimSpace(parts[0])] = strings.TrimSpace(parts[1])
|
||||||
|
}
|
||||||
|
if s := table["time to empty"]; s == "" {
|
||||||
|
table["time to empty"] = "∞"
|
||||||
|
}
|
||||||
|
str := ""
|
||||||
|
str = str + fmt.Sprintf(" %10s: %s\n", "Charge", battery.formatCharge(table["percentage"]))
|
||||||
|
str = str + fmt.Sprintf(" %10s: %s\n", "Remaining", table["time to empty"])
|
||||||
|
str = str + fmt.Sprintf(" %10s: %s\n", "State", battery.formatState(table["state"]))
|
||||||
|
if s := table["time to full"]; s != "" {
|
||||||
|
str = str + fmt.Sprintf(" %10s: %s\n", "TimeToFull", table["time to full"])
|
||||||
|
}
|
||||||
|
batteryState = table["state"]
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|
||||||
|
func (battery *Battery) formatCharge(data string) string {
|
||||||
|
percent, _ := strconv.ParseFloat(strings.Replace(data, "%", "", -1), 32)
|
||||||
|
color := ""
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case percent >= 70:
|
||||||
|
color = "[green]"
|
||||||
|
case percent >= 35:
|
||||||
|
color = "[yellow]"
|
||||||
|
default:
|
||||||
|
color = "[red]"
|
||||||
|
}
|
||||||
|
|
||||||
|
return color + data + "[white]"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (battery *Battery) formatState(data string) string {
|
||||||
|
color := ""
|
||||||
|
|
||||||
|
switch data {
|
||||||
|
case "charging":
|
||||||
|
color = "[green]"
|
||||||
|
case "discharging":
|
||||||
|
color = "[yellow]"
|
||||||
|
default:
|
||||||
|
color = "[white]"
|
||||||
|
}
|
||||||
|
|
||||||
|
return color + data + "[white]"
|
||||||
|
}
|
@ -1,3 +1,5 @@
|
|||||||
|
// +build !linux
|
||||||
|
|
||||||
package power
|
package power
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
15
power/source_linux.go
Normal file
15
power/source_linux.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// +build linux
|
||||||
|
|
||||||
|
package power
|
||||||
|
|
||||||
|
// powerSource returns the name of the current power source, probably one of
|
||||||
|
// "AC Power" or "Battery Power"
|
||||||
|
func powerSource() string {
|
||||||
|
switch batteryState {
|
||||||
|
case "charging", "fully-charged":
|
||||||
|
return "AC Power"
|
||||||
|
case "discharging":
|
||||||
|
return "Battery Power"
|
||||||
|
}
|
||||||
|
return batteryState
|
||||||
|
}
|
@ -22,7 +22,8 @@ func NewSystemInfo() *SystemInfo {
|
|||||||
var cmd *exec.Cmd
|
var cmd *exec.Cmd
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "linux":
|
case "linux":
|
||||||
cmd = exec.Command("uname -a", arg...)
|
arg = append(arg, "-a")
|
||||||
|
cmd = exec.Command("lsb_release", arg...)
|
||||||
case "darwin":
|
case "darwin":
|
||||||
cmd = exec.Command("sw_vers", arg...)
|
cmd = exec.Command("sw_vers", arg...)
|
||||||
default:
|
default:
|
||||||
@ -33,7 +34,6 @@ func NewSystemInfo() *SystemInfo {
|
|||||||
|
|
||||||
for _, row := range strings.Split(raw, "\n") {
|
for _, row := range strings.Split(raw, "\n") {
|
||||||
parts := strings.Split(row, ":")
|
parts := strings.Split(row, ":")
|
||||||
|
|
||||||
if len(parts) < 2 {
|
if len(parts) < 2 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package todo
|
package todo
|
||||||
|
|
||||||
import ()
|
|
||||||
|
|
||||||
type Item struct {
|
type Item struct {
|
||||||
Checked bool
|
Checked bool
|
||||||
Text string
|
Text string
|
||||||
|
15
vendor/cloud.google.com/go/AUTHORS
generated
vendored
Normal file
15
vendor/cloud.google.com/go/AUTHORS
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# This is the official list of cloud authors for copyright purposes.
|
||||||
|
# This file is distinct from the CONTRIBUTORS files.
|
||||||
|
# See the latter for an explanation.
|
||||||
|
|
||||||
|
# Names should be added to this file as:
|
||||||
|
# Name or Organization <email address>
|
||||||
|
# The email address is not required for organizations.
|
||||||
|
|
||||||
|
Filippo Valsorda <hi@filippo.io>
|
||||||
|
Google Inc.
|
||||||
|
Ingo Oeser <nightlyone@googlemail.com>
|
||||||
|
Palm Stone Games, Inc.
|
||||||
|
Paweł Knap <pawelknap88@gmail.com>
|
||||||
|
Péter Szilágyi <peterke@gmail.com>
|
||||||
|
Tyler Treat <ttreat31@gmail.com>
|
40
vendor/cloud.google.com/go/CONTRIBUTORS
generated
vendored
Normal file
40
vendor/cloud.google.com/go/CONTRIBUTORS
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# People who have agreed to one of the CLAs and can contribute patches.
|
||||||
|
# The AUTHORS file lists the copyright holders; this file
|
||||||
|
# lists people. For example, Google employees are listed here
|
||||||
|
# but not in AUTHORS, because Google holds the copyright.
|
||||||
|
#
|
||||||
|
# https://developers.google.com/open-source/cla/individual
|
||||||
|
# https://developers.google.com/open-source/cla/corporate
|
||||||
|
#
|
||||||
|
# Names should be added to this file as:
|
||||||
|
# Name <email address>
|
||||||
|
|
||||||
|
# Keep the list alphabetically sorted.
|
||||||
|
|
||||||
|
Alexis Hunt <lexer@google.com>
|
||||||
|
Andreas Litt <andreas.litt@gmail.com>
|
||||||
|
Andrew Gerrand <adg@golang.org>
|
||||||
|
Brad Fitzpatrick <bradfitz@golang.org>
|
||||||
|
Burcu Dogan <jbd@google.com>
|
||||||
|
Dave Day <djd@golang.org>
|
||||||
|
David Sansome <me@davidsansome.com>
|
||||||
|
David Symonds <dsymonds@golang.org>
|
||||||
|
Filippo Valsorda <hi@filippo.io>
|
||||||
|
Glenn Lewis <gmlewis@google.com>
|
||||||
|
Ingo Oeser <nightlyone@googlemail.com>
|
||||||
|
James Hall <james.hall@shopify.com>
|
||||||
|
Johan Euphrosine <proppy@google.com>
|
||||||
|
Jonathan Amsterdam <jba@google.com>
|
||||||
|
Kunpei Sakai <namusyaka@gmail.com>
|
||||||
|
Luna Duclos <luna.duclos@palmstonegames.com>
|
||||||
|
Magnus Hiie <magnus.hiie@gmail.com>
|
||||||
|
Mario Castro <mariocaster@gmail.com>
|
||||||
|
Michael McGreevy <mcgreevy@golang.org>
|
||||||
|
Omar Jarjur <ojarjur@google.com>
|
||||||
|
Paweł Knap <pawelknap88@gmail.com>
|
||||||
|
Péter Szilágyi <peterke@gmail.com>
|
||||||
|
Sarah Adams <shadams@google.com>
|
||||||
|
Thanatat Tamtan <acoshift@gmail.com>
|
||||||
|
Toby Burress <kurin@google.com>
|
||||||
|
Tuo Shan <shantuo@google.com>
|
||||||
|
Tyler Treat <ttreat31@gmail.com>
|
202
vendor/cloud.google.com/go/LICENSE
generated
vendored
Normal file
202
vendor/cloud.google.com/go/LICENSE
generated
vendored
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
437
vendor/cloud.google.com/go/compute/metadata/metadata.go
generated
vendored
Normal file
437
vendor/cloud.google.com/go/compute/metadata/metadata.go
generated
vendored
Normal file
@ -0,0 +1,437 @@
|
|||||||
|
// Copyright 2014 Google Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// Package metadata provides access to Google Compute Engine (GCE)
|
||||||
|
// metadata and API service accounts.
|
||||||
|
//
|
||||||
|
// This package is a wrapper around the GCE metadata service,
|
||||||
|
// as documented at https://developers.google.com/compute/docs/metadata.
|
||||||
|
package metadata // import "cloud.google.com/go/compute/metadata"
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"os"
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/net/context"
|
||||||
|
"golang.org/x/net/context/ctxhttp"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// metadataIP is the documented metadata server IP address.
|
||||||
|
metadataIP = "169.254.169.254"
|
||||||
|
|
||||||
|
// metadataHostEnv is the environment variable specifying the
|
||||||
|
// GCE metadata hostname. If empty, the default value of
|
||||||
|
// metadataIP ("169.254.169.254") is used instead.
|
||||||
|
// This is variable name is not defined by any spec, as far as
|
||||||
|
// I know; it was made up for the Go package.
|
||||||
|
metadataHostEnv = "GCE_METADATA_HOST"
|
||||||
|
|
||||||
|
userAgent = "gcloud-golang/0.1"
|
||||||
|
)
|
||||||
|
|
||||||
|
type cachedValue struct {
|
||||||
|
k string
|
||||||
|
trim bool
|
||||||
|
mu sync.Mutex
|
||||||
|
v string
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
projID = &cachedValue{k: "project/project-id", trim: true}
|
||||||
|
projNum = &cachedValue{k: "project/numeric-project-id", trim: true}
|
||||||
|
instID = &cachedValue{k: "instance/id", trim: true}
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
metaClient = &http.Client{
|
||||||
|
Transport: &http.Transport{
|
||||||
|
Dial: (&net.Dialer{
|
||||||
|
Timeout: 2 * time.Second,
|
||||||
|
KeepAlive: 30 * time.Second,
|
||||||
|
}).Dial,
|
||||||
|
ResponseHeaderTimeout: 2 * time.Second,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
subscribeClient = &http.Client{
|
||||||
|
Transport: &http.Transport{
|
||||||
|
Dial: (&net.Dialer{
|
||||||
|
Timeout: 2 * time.Second,
|
||||||
|
KeepAlive: 30 * time.Second,
|
||||||
|
}).Dial,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// NotDefinedError is returned when requested metadata is not defined.
|
||||||
|
//
|
||||||
|
// The underlying string is the suffix after "/computeMetadata/v1/".
|
||||||
|
//
|
||||||
|
// This error is not returned if the value is defined to be the empty
|
||||||
|
// string.
|
||||||
|
type NotDefinedError string
|
||||||
|
|
||||||
|
func (suffix NotDefinedError) Error() string {
|
||||||
|
return fmt.Sprintf("metadata: GCE metadata %q not defined", string(suffix))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get returns a value from the metadata service.
|
||||||
|
// The suffix is appended to "http://${GCE_METADATA_HOST}/computeMetadata/v1/".
|
||||||
|
//
|
||||||
|
// If the GCE_METADATA_HOST environment variable is not defined, a default of
|
||||||
|
// 169.254.169.254 will be used instead.
|
||||||
|
//
|
||||||
|
// If the requested metadata is not defined, the returned error will
|
||||||
|
// be of type NotDefinedError.
|
||||||
|
func Get(suffix string) (string, error) {
|
||||||
|
val, _, err := getETag(metaClient, suffix)
|
||||||
|
return val, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// getETag returns a value from the metadata service as well as the associated
|
||||||
|
// ETag using the provided client. This func is otherwise equivalent to Get.
|
||||||
|
func getETag(client *http.Client, suffix string) (value, etag string, err error) {
|
||||||
|
// Using a fixed IP makes it very difficult to spoof the metadata service in
|
||||||
|
// a container, which is an important use-case for local testing of cloud
|
||||||
|
// deployments. To enable spoofing of the metadata service, the environment
|
||||||
|
// variable GCE_METADATA_HOST is first inspected to decide where metadata
|
||||||
|
// requests shall go.
|
||||||
|
host := os.Getenv(metadataHostEnv)
|
||||||
|
if host == "" {
|
||||||
|
// Using 169.254.169.254 instead of "metadata" here because Go
|
||||||
|
// binaries built with the "netgo" tag and without cgo won't
|
||||||
|
// know the search suffix for "metadata" is
|
||||||
|
// ".google.internal", and this IP address is documented as
|
||||||
|
// being stable anyway.
|
||||||
|
host = metadataIP
|
||||||
|
}
|
||||||
|
url := "http://" + host + "/computeMetadata/v1/" + suffix
|
||||||
|
req, _ := http.NewRequest("GET", url, nil)
|
||||||
|
req.Header.Set("Metadata-Flavor", "Google")
|
||||||
|
req.Header.Set("User-Agent", userAgent)
|
||||||
|
res, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return "", "", err
|
||||||
|
}
|
||||||
|
defer res.Body.Close()
|
||||||
|
if res.StatusCode == http.StatusNotFound {
|
||||||
|
return "", "", NotDefinedError(suffix)
|
||||||
|
}
|
||||||
|
if res.StatusCode != 200 {
|
||||||
|
return "", "", fmt.Errorf("status code %d trying to fetch %s", res.StatusCode, url)
|
||||||
|
}
|
||||||
|
all, err := ioutil.ReadAll(res.Body)
|
||||||
|
if err != nil {
|
||||||
|
return "", "", err
|
||||||
|
}
|
||||||
|
return string(all), res.Header.Get("Etag"), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func getTrimmed(suffix string) (s string, err error) {
|
||||||
|
s, err = Get(suffix)
|
||||||
|
s = strings.TrimSpace(s)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *cachedValue) get() (v string, err error) {
|
||||||
|
defer c.mu.Unlock()
|
||||||
|
c.mu.Lock()
|
||||||
|
if c.v != "" {
|
||||||
|
return c.v, nil
|
||||||
|
}
|
||||||
|
if c.trim {
|
||||||
|
v, err = getTrimmed(c.k)
|
||||||
|
} else {
|
||||||
|
v, err = Get(c.k)
|
||||||
|
}
|
||||||
|
if err == nil {
|
||||||
|
c.v = v
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
onGCEOnce sync.Once
|
||||||
|
onGCE bool
|
||||||
|
)
|
||||||
|
|
||||||
|
// OnGCE reports whether this process is running on Google Compute Engine.
|
||||||
|
func OnGCE() bool {
|
||||||
|
onGCEOnce.Do(initOnGCE)
|
||||||
|
return onGCE
|
||||||
|
}
|
||||||
|
|
||||||
|
func initOnGCE() {
|
||||||
|
onGCE = testOnGCE()
|
||||||
|
}
|
||||||
|
|
||||||
|
func testOnGCE() bool {
|
||||||
|
// The user explicitly said they're on GCE, so trust them.
|
||||||
|
if os.Getenv(metadataHostEnv) != "" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
resc := make(chan bool, 2)
|
||||||
|
|
||||||
|
// Try two strategies in parallel.
|
||||||
|
// See https://github.com/GoogleCloudPlatform/google-cloud-go/issues/194
|
||||||
|
go func() {
|
||||||
|
req, _ := http.NewRequest("GET", "http://"+metadataIP, nil)
|
||||||
|
req.Header.Set("User-Agent", userAgent)
|
||||||
|
res, err := ctxhttp.Do(ctx, metaClient, req)
|
||||||
|
if err != nil {
|
||||||
|
resc <- false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer res.Body.Close()
|
||||||
|
resc <- res.Header.Get("Metadata-Flavor") == "Google"
|
||||||
|
}()
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
addrs, err := net.LookupHost("metadata.google.internal")
|
||||||
|
if err != nil || len(addrs) == 0 {
|
||||||
|
resc <- false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resc <- strsContains(addrs, metadataIP)
|
||||||
|
}()
|
||||||
|
|
||||||
|
tryHarder := systemInfoSuggestsGCE()
|
||||||
|
if tryHarder {
|
||||||
|
res := <-resc
|
||||||
|
if res {
|
||||||
|
// The first strategy succeeded, so let's use it.
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
// Wait for either the DNS or metadata server probe to
|
||||||
|
// contradict the other one and say we are running on
|
||||||
|
// GCE. Give it a lot of time to do so, since the system
|
||||||
|
// info already suggests we're running on a GCE BIOS.
|
||||||
|
timer := time.NewTimer(5 * time.Second)
|
||||||
|
defer timer.Stop()
|
||||||
|
select {
|
||||||
|
case res = <-resc:
|
||||||
|
return res
|
||||||
|
case <-timer.C:
|
||||||
|
// Too slow. Who knows what this system is.
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// There's no hint from the system info that we're running on
|
||||||
|
// GCE, so use the first probe's result as truth, whether it's
|
||||||
|
// true or false. The goal here is to optimize for speed for
|
||||||
|
// users who are NOT running on GCE. We can't assume that
|
||||||
|
// either a DNS lookup or an HTTP request to a blackholed IP
|
||||||
|
// address is fast. Worst case this should return when the
|
||||||
|
// metaClient's Transport.ResponseHeaderTimeout or
|
||||||
|
// Transport.Dial.Timeout fires (in two seconds).
|
||||||
|
return <-resc
|
||||||
|
}
|
||||||
|
|
||||||
|
// systemInfoSuggestsGCE reports whether the local system (without
|
||||||
|
// doing network requests) suggests that we're running on GCE. If this
|
||||||
|
// returns true, testOnGCE tries a bit harder to reach its metadata
|
||||||
|
// server.
|
||||||
|
func systemInfoSuggestsGCE() bool {
|
||||||
|
if runtime.GOOS != "linux" {
|
||||||
|
// We don't have any non-Linux clues available, at least yet.
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
slurp, _ := ioutil.ReadFile("/sys/class/dmi/id/product_name")
|
||||||
|
name := strings.TrimSpace(string(slurp))
|
||||||
|
return name == "Google" || name == "Google Compute Engine"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subscribe subscribes to a value from the metadata service.
|
||||||
|
// The suffix is appended to "http://${GCE_METADATA_HOST}/computeMetadata/v1/".
|
||||||
|
// The suffix may contain query parameters.
|
||||||
|
//
|
||||||
|
// Subscribe calls fn with the latest metadata value indicated by the provided
|
||||||
|
// suffix. If the metadata value is deleted, fn is called with the empty string
|
||||||
|
// and ok false. Subscribe blocks until fn returns a non-nil error or the value
|
||||||
|
// is deleted. Subscribe returns the error value returned from the last call to
|
||||||
|
// fn, which may be nil when ok == false.
|
||||||
|
func Subscribe(suffix string, fn func(v string, ok bool) error) error {
|
||||||
|
const failedSubscribeSleep = time.Second * 5
|
||||||
|
|
||||||
|
// First check to see if the metadata value exists at all.
|
||||||
|
val, lastETag, err := getETag(subscribeClient, suffix)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := fn(val, true); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
ok := true
|
||||||
|
if strings.ContainsRune(suffix, '?') {
|
||||||
|
suffix += "&wait_for_change=true&last_etag="
|
||||||
|
} else {
|
||||||
|
suffix += "?wait_for_change=true&last_etag="
|
||||||
|
}
|
||||||
|
for {
|
||||||
|
val, etag, err := getETag(subscribeClient, suffix+url.QueryEscape(lastETag))
|
||||||
|
if err != nil {
|
||||||
|
if _, deleted := err.(NotDefinedError); !deleted {
|
||||||
|
time.Sleep(failedSubscribeSleep)
|
||||||
|
continue // Retry on other errors.
|
||||||
|
}
|
||||||
|
ok = false
|
||||||
|
}
|
||||||
|
lastETag = etag
|
||||||
|
|
||||||
|
if err := fn(val, ok); err != nil || !ok {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProjectID returns the current instance's project ID string.
|
||||||
|
func ProjectID() (string, error) { return projID.get() }
|
||||||
|
|
||||||
|
// NumericProjectID returns the current instance's numeric project ID.
|
||||||
|
func NumericProjectID() (string, error) { return projNum.get() }
|
||||||
|
|
||||||
|
// InternalIP returns the instance's primary internal IP address.
|
||||||
|
func InternalIP() (string, error) {
|
||||||
|
return getTrimmed("instance/network-interfaces/0/ip")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExternalIP returns the instance's primary external (public) IP address.
|
||||||
|
func ExternalIP() (string, error) {
|
||||||
|
return getTrimmed("instance/network-interfaces/0/access-configs/0/external-ip")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hostname returns the instance's hostname. This will be of the form
|
||||||
|
// "<instanceID>.c.<projID>.internal".
|
||||||
|
func Hostname() (string, error) {
|
||||||
|
return getTrimmed("instance/hostname")
|
||||||
|
}
|
||||||
|
|
||||||
|
// InstanceTags returns the list of user-defined instance tags,
|
||||||
|
// assigned when initially creating a GCE instance.
|
||||||
|
func InstanceTags() ([]string, error) {
|
||||||
|
var s []string
|
||||||
|
j, err := Get("instance/tags")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := json.NewDecoder(strings.NewReader(j)).Decode(&s); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return s, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// InstanceID returns the current VM's numeric instance ID.
|
||||||
|
func InstanceID() (string, error) {
|
||||||
|
return instID.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
// InstanceName returns the current VM's instance ID string.
|
||||||
|
func InstanceName() (string, error) {
|
||||||
|
host, err := Hostname()
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return strings.Split(host, ".")[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zone returns the current VM's zone, such as "us-central1-b".
|
||||||
|
func Zone() (string, error) {
|
||||||
|
zone, err := getTrimmed("instance/zone")
|
||||||
|
// zone is of the form "projects/<projNum>/zones/<zoneName>".
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return zone[strings.LastIndex(zone, "/")+1:], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// InstanceAttributes returns the list of user-defined attributes,
|
||||||
|
// assigned when initially creating a GCE VM instance. The value of an
|
||||||
|
// attribute can be obtained with InstanceAttributeValue.
|
||||||
|
func InstanceAttributes() ([]string, error) { return lines("instance/attributes/") }
|
||||||
|
|
||||||
|
// ProjectAttributes returns the list of user-defined attributes
|
||||||
|
// applying to the project as a whole, not just this VM. The value of
|
||||||
|
// an attribute can be obtained with ProjectAttributeValue.
|
||||||
|
func ProjectAttributes() ([]string, error) { return lines("project/attributes/") }
|
||||||
|
|
||||||
|
func lines(suffix string) ([]string, error) {
|
||||||
|
j, err := Get(suffix)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
s := strings.Split(strings.TrimSpace(j), "\n")
|
||||||
|
for i := range s {
|
||||||
|
s[i] = strings.TrimSpace(s[i])
|
||||||
|
}
|
||||||
|
return s, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// InstanceAttributeValue returns the value of the provided VM
|
||||||
|
// instance attribute.
|
||||||
|
//
|
||||||
|
// If the requested attribute is not defined, the returned error will
|
||||||
|
// be of type NotDefinedError.
|
||||||
|
//
|
||||||
|
// InstanceAttributeValue may return ("", nil) if the attribute was
|
||||||
|
// defined to be the empty string.
|
||||||
|
func InstanceAttributeValue(attr string) (string, error) {
|
||||||
|
return Get("instance/attributes/" + attr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProjectAttributeValue returns the value of the provided
|
||||||
|
// project attribute.
|
||||||
|
//
|
||||||
|
// If the requested attribute is not defined, the returned error will
|
||||||
|
// be of type NotDefinedError.
|
||||||
|
//
|
||||||
|
// ProjectAttributeValue may return ("", nil) if the attribute was
|
||||||
|
// defined to be the empty string.
|
||||||
|
func ProjectAttributeValue(attr string) (string, error) {
|
||||||
|
return Get("project/attributes/" + attr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scopes returns the service account scopes for the given account.
|
||||||
|
// The account may be empty or the string "default" to use the instance's
|
||||||
|
// main account.
|
||||||
|
func Scopes(serviceAccount string) ([]string, error) {
|
||||||
|
if serviceAccount == "" {
|
||||||
|
serviceAccount = "default"
|
||||||
|
}
|
||||||
|
return lines("instance/service-accounts/" + serviceAccount + "/scopes")
|
||||||
|
}
|
||||||
|
|
||||||
|
func strsContains(ss []string, s string) bool {
|
||||||
|
for _, v := range ss {
|
||||||
|
if v == s {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
31
vendor/github.com/briandowns/openweathermap/.gitignore
generated
vendored
Normal file
31
vendor/github.com/briandowns/openweathermap/.gitignore
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# Created by .gitignore support plugin (hsz.mobi)
|
||||||
|
### Go template
|
||||||
|
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||||
|
*.o
|
||||||
|
*.a
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Folders
|
||||||
|
_obj
|
||||||
|
_test
|
||||||
|
|
||||||
|
# Architecture specific extensions/prefixes
|
||||||
|
*.[568vq]
|
||||||
|
[568vq].out
|
||||||
|
|
||||||
|
*.cgo1.go
|
||||||
|
*.cgo2.c
|
||||||
|
_cgo_defun.c
|
||||||
|
_cgo_gotypes.go
|
||||||
|
_cgo_export.*
|
||||||
|
|
||||||
|
_testmain.go
|
||||||
|
|
||||||
|
*.exe
|
||||||
|
*.test
|
||||||
|
*.prof
|
||||||
|
|
||||||
|
.idea
|
||||||
|
*.iml
|
||||||
|
|
||||||
|
coverage.*
|
29
vendor/github.com/briandowns/openweathermap/.travis.yml
generated
vendored
Normal file
29
vendor/github.com/briandowns/openweathermap/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
language: go
|
||||||
|
go:
|
||||||
|
- 1.5.4
|
||||||
|
- 1.6.2
|
||||||
|
env:
|
||||||
|
- GOARCH: amd64
|
||||||
|
- GOARCH: 386
|
||||||
|
addons:
|
||||||
|
hosts:
|
||||||
|
- api.openweathermap.org
|
||||||
|
before_install:
|
||||||
|
- sudo apt-get -qq update
|
||||||
|
- sudo apt-get install -y socat
|
||||||
|
- cat /etc/hosts
|
||||||
|
- wget http://ipinfo.io/ip -qO -
|
||||||
|
- sudo socat TCP-LISTEN:80,fork TCP:${RTCP_HOST}:${RTCP_PORT} > /tmp/socat.log 2>&1 &
|
||||||
|
- go get github.com/mattn/goveralls
|
||||||
|
- go get golang.org/x/tools/cmd/cover
|
||||||
|
script:
|
||||||
|
- make test
|
||||||
|
- $HOME/gopath/bin/goveralls -service=travis-ci -repotoken $COVERALLS_TOKEN
|
||||||
|
notifications:
|
||||||
|
email:
|
||||||
|
recipients:
|
||||||
|
- brian.downs@gmail.com
|
||||||
|
on_success: change
|
||||||
|
on_failure: always
|
||||||
|
after_success:
|
||||||
|
- coveralls
|
14
vendor/github.com/briandowns/openweathermap/CONTRIBUTING.md
generated
vendored
Normal file
14
vendor/github.com/briandowns/openweathermap/CONTRIBUTING.md
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# Contributing to openweathermap
|
||||||
|
|
||||||
|
## Issues
|
||||||
|
|
||||||
|
### Reporting an Issue
|
||||||
|
|
||||||
|
* Please add an issue [here](https://github.com/briandowns/openweathermap/issues) and utilize the appropriate label.
|
||||||
|
|
||||||
|
## Fixing Problems and/or Adding Features
|
||||||
|
|
||||||
|
* Feel free to fork and fix an issue(s) or add a feature.
|
||||||
|
* Please provide tests for the submitted code.
|
||||||
|
* Run `go fmt` and `go vet`
|
||||||
|
* Once the pull request is submitted, it'll be tested and merged.
|
174
vendor/github.com/briandowns/openweathermap/LICENSE
generated
vendored
Normal file
174
vendor/github.com/briandowns/openweathermap/LICENSE
generated
vendored
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
19
vendor/github.com/briandowns/openweathermap/Makefile
generated
vendored
Normal file
19
vendor/github.com/briandowns/openweathermap/Makefile
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
GOCMD = go
|
||||||
|
GOBUILD = $(GOCMD) build
|
||||||
|
GOGET = $(GOCMD) get -v
|
||||||
|
GOCLEAN = $(GOCMD) clean
|
||||||
|
GOINSTALL = $(GOCMD) install
|
||||||
|
GOTEST = $(GOCMD) test
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
|
||||||
|
all: test
|
||||||
|
|
||||||
|
test:
|
||||||
|
$(GOTEST) -v -covermode=count -coverprofile=coverage.out ./...
|
||||||
|
|
||||||
|
build: test
|
||||||
|
$(GOBUILD)
|
||||||
|
|
||||||
|
install: test
|
||||||
|
$(GOINSTALL)
|
265
vendor/github.com/briandowns/openweathermap/README.md
generated
vendored
Normal file
265
vendor/github.com/briandowns/openweathermap/README.md
generated
vendored
Normal file
@ -0,0 +1,265 @@
|
|||||||
|
# OpenWeatherMap Go API
|
||||||
|
|
||||||
|
[](https://godoc.org/github.com/briandowns/openweathermap) [](https://travis-ci.org/briandowns/openweathermap) [](https://coveralls.io/github/briandowns/openweathermap?branch=master)
|
||||||
|
|
||||||
|
Go (golang) package for use with openweathermap.org's API.
|
||||||
|
|
||||||
|
For more detail about the library and its features, reference your local godoc once installed.
|
||||||
|
|
||||||
|
[Website](https://briandowns.github.io/openweathermap)!
|
||||||
|
|
||||||
|
To use the OpenweatherMap API, you need to obtain an API key. Sign up [here](http://home.openweathermap.org/users/sign_up). Once you have your key, create an environment variable called `OWM_API_KEY`. Start coding!
|
||||||
|
|
||||||
|
[Slack Channel](https://openweathermapgolang.slack.com/messages/general)
|
||||||
|
|
||||||
|
Contributions welcome!
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
### Current Weather Conditions
|
||||||
|
|
||||||
|
- By City
|
||||||
|
- By City,St (State)
|
||||||
|
- By City,Co (Country)
|
||||||
|
- By City ID
|
||||||
|
- By Zip,Co (Country)
|
||||||
|
- By Longitude and Latitude
|
||||||
|
|
||||||
|
## Forecast
|
||||||
|
|
||||||
|
Get the weather conditions for a given number of days.
|
||||||
|
|
||||||
|
- By City
|
||||||
|
- By City,St (State)
|
||||||
|
- By City,Co (Country)
|
||||||
|
- By City ID
|
||||||
|
- By Longitude and Latitude
|
||||||
|
|
||||||
|
### Access to Condition Codes and Icons
|
||||||
|
|
||||||
|
Gain access to OpenWeatherMap icons and condition codes.
|
||||||
|
|
||||||
|
- Thunderstorms
|
||||||
|
- Drizzle
|
||||||
|
- Rain
|
||||||
|
- Snow
|
||||||
|
- Atmosphere
|
||||||
|
- Clouds
|
||||||
|
- Extreme
|
||||||
|
- Additional
|
||||||
|
|
||||||
|
### Data Available in Multiple Measurement Systems
|
||||||
|
|
||||||
|
- Fahrenheit (OpenWeatherMap API - imperial)
|
||||||
|
- Celsius (OpenWeatherMap API - metric)
|
||||||
|
- Kelvin (OpenWeatherMap API - internal)
|
||||||
|
|
||||||
|
### UV Index Data
|
||||||
|
|
||||||
|
- Current
|
||||||
|
- Historical
|
||||||
|
|
||||||
|
### Pollution Data
|
||||||
|
|
||||||
|
- Current
|
||||||
|
|
||||||
|
## Historical Conditions
|
||||||
|
|
||||||
|
- By Name
|
||||||
|
- By ID
|
||||||
|
- By Coordinates
|
||||||
|
|
||||||
|
## Supported Languages
|
||||||
|
|
||||||
|
English - en, Russian - ru, Italian - it, Spanish - es (or sp), Ukrainian - uk (or ua), German - de, Portuguese - pt, Romanian - ro, Polish - pl, Finnish - fi, Dutch - nl, French - fr, Bulgarian - bg, Swedish - sv (or se), Chinese Traditional - zh_tw, Chinese Simplified - zh (or zh_cn), Turkish - tr, Croatian - hr, Catalan - ca
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go get github.com/briandowns/openweathermap
|
||||||
|
```
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
There are a few full examples in the examples directory that can be referenced. 1 is a command line application and 1 is a simple web application.
|
||||||
|
|
||||||
|
```Go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
// Shortening the import reference name seems to make it a bit easier
|
||||||
|
owm "github.com/briandowns/openweathermap"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
w, err := owm.NewCurrent("F", "ru") // fahrenheit (imperial) with Russian output
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
w.CurrentByName("Phoenix")
|
||||||
|
fmt.Println(w)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Current Conditions by location name
|
||||||
|
|
||||||
|
```Go
|
||||||
|
func main() {
|
||||||
|
w, err := owm.NewCurrent("K", "EN") // (internal - OpenWeatherMap reference for kelvin) with English output
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
w.CurrentByName("Phoenix,AZ")
|
||||||
|
fmt.Println(w)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Forecast Conditions in imperial (fahrenheit) by coordinates
|
||||||
|
|
||||||
|
```Go
|
||||||
|
func main() {
|
||||||
|
w, err := owm.NewForecast("F", "FI")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
w.DailyByCoordinates(
|
||||||
|
&Coordinates{
|
||||||
|
Longitude: -112.07,
|
||||||
|
Latitude: 33.45,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
fmt.Println(w)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Current conditions in metric (celsius) by location ID
|
||||||
|
|
||||||
|
```Go
|
||||||
|
func main() {
|
||||||
|
w, err := owm.NewCurrent("C", "PL")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
w.CurrentByID(2172797)
|
||||||
|
fmt.Println(w)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Current conditions by zip code. 2 character country code required
|
||||||
|
|
||||||
|
```Go
|
||||||
|
func main() {
|
||||||
|
w, err := owm.NewCurrent("F", "EN")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
w.CurrentByZip(19125, "US")
|
||||||
|
fmt.Println(w)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configure http client
|
||||||
|
|
||||||
|
```Go
|
||||||
|
func main() {
|
||||||
|
client := &http.Client{}
|
||||||
|
w, err := owm.NewCurrent("F", "EN", owm.WithHttpClient(client))
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Current UV conditions
|
||||||
|
|
||||||
|
```Go
|
||||||
|
func main() {
|
||||||
|
uv, err := NewUV()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
coord := &Coordinates{
|
||||||
|
Longitude: 53.343497,
|
||||||
|
Latitude: -6.288379,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := uv.Current(coord); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Historical UV conditions
|
||||||
|
|
||||||
|
```Go
|
||||||
|
func main() {
|
||||||
|
uv, err := NewUV()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
coord := &Coordinates{
|
||||||
|
Longitude: 54.995656,
|
||||||
|
Latitude: -7.326834,
|
||||||
|
}
|
||||||
|
|
||||||
|
end := time.Now().UTC()
|
||||||
|
start := time.Now().UTC().Add(-time.Hour * time.Duration(24))
|
||||||
|
|
||||||
|
if err := uv.Historical(coord, start, end); err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### UV Information
|
||||||
|
|
||||||
|
```Go
|
||||||
|
func main() {
|
||||||
|
uv, err := NewUV()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := uv.Current(coords); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
info, err := uv.UVInformation()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Pollution Information
|
||||||
|
|
||||||
|
```Go
|
||||||
|
func main() {
|
||||||
|
pollution, err := NewPollution()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
params := &PollutionParameters{
|
||||||
|
Location: Coordinates{
|
||||||
|
Latitude: 0.0,
|
||||||
|
Longitude: 10.0,
|
||||||
|
},
|
||||||
|
Datetime: "current",
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := pollution.PollutionByParams(params); err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
185
vendor/github.com/briandowns/openweathermap/conditions.go
generated
vendored
Normal file
185
vendor/github.com/briandowns/openweathermap/conditions.go
generated
vendored
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
// Copyright 2015 Brian J. Downs
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package openweathermap
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IconData holds the relevant info for linking icons to conditions.
|
||||||
|
type IconData struct {
|
||||||
|
Condition string
|
||||||
|
Day string
|
||||||
|
Night string
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConditionData holds data structure for weather conditions information.
|
||||||
|
type ConditionData struct {
|
||||||
|
ID int
|
||||||
|
Meaning string
|
||||||
|
Icon1 string
|
||||||
|
Icon2 string
|
||||||
|
}
|
||||||
|
|
||||||
|
// RetrieveIcon will get the specified icon from the API.
|
||||||
|
func RetrieveIcon(destination, iconFile string) (int64, error) {
|
||||||
|
fullFilePath := fmt.Sprintf("%s/%s", destination, iconFile)
|
||||||
|
|
||||||
|
// Check to see if we've already gotten that icon file. If so, use it
|
||||||
|
// rather than getting it again.
|
||||||
|
if _, err := os.Stat(fullFilePath); err != nil {
|
||||||
|
response, err := http.Get(fmt.Sprintf(iconURL, iconFile))
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
|
|
||||||
|
// Create the icon file
|
||||||
|
out, err := os.Create(fullFilePath)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
defer out.Close()
|
||||||
|
|
||||||
|
// Fill the empty file with the actual content
|
||||||
|
n, err := io.Copy(out, response.Body)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return n, nil
|
||||||
|
}
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IconList is a slice of IconData pointers
|
||||||
|
var IconList = []*IconData{
|
||||||
|
{Condition: "clear sky", Day: "01d.png", Night: "01n.png"},
|
||||||
|
{Condition: "few clouds", Day: "02d.png", Night: "02n.png"},
|
||||||
|
{Condition: "scattered clouds", Day: "03d.png", Night: "03n.png"},
|
||||||
|
{Condition: "broken clouds", Day: "04d.png", Night: "04n.png"},
|
||||||
|
{Condition: "shower rain", Day: "09d.png", Night: "09n.png"},
|
||||||
|
{Condition: "rain", Day: "10d.png", Night: "10n.png"},
|
||||||
|
{Condition: "thunderstorm", Day: "11d.png", Night: "11n.png"},
|
||||||
|
{Condition: "snow", Day: "13d.png", Night: "13n.png"},
|
||||||
|
{Condition: "mist", Day: "50d.png", Night: "50n.png"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// ThunderstormConditions is a slice of ConditionData pointers
|
||||||
|
var ThunderstormConditions = []*ConditionData{
|
||||||
|
{ID: 200, Meaning: "thunderstorm with light rain", Icon1: "11d.png"},
|
||||||
|
{ID: 201, Meaning: "thunderstorm with rain", Icon1: "11d.png"},
|
||||||
|
{ID: 202, Meaning: "thunderstorm with heavy rain", Icon1: "11d.png"},
|
||||||
|
{ID: 210, Meaning: "light thunderstorm", Icon1: "11d.png"},
|
||||||
|
{ID: 211, Meaning: "thunderstorm", Icon1: "11d.png"},
|
||||||
|
{ID: 212, Meaning: "heavy thunderstorm", Icon1: "11d.png"},
|
||||||
|
{ID: 221, Meaning: "ragged thunderstorm", Icon1: "11d.png"},
|
||||||
|
{ID: 230, Meaning: "thunderstorm with light drizzle", Icon1: "11d.png"},
|
||||||
|
{ID: 231, Meaning: "thunderstorm with drizzle", Icon1: "11d.png"},
|
||||||
|
{ID: 232, Meaning: "thunderstorm with heavy drizzle", Icon1: "11d.png"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// DrizzleConditions is a slice of ConditionData pointers
|
||||||
|
var DrizzleConditions = []*ConditionData{
|
||||||
|
{ID: 300, Meaning: "light intensity drizzle", Icon1: "09d.png"},
|
||||||
|
{ID: 301, Meaning: "drizzle", Icon1: "09d.png"},
|
||||||
|
{ID: 302, Meaning: "heavy intensity drizzle", Icon1: "09d.png"},
|
||||||
|
{ID: 310, Meaning: "light intensity drizzle rain", Icon1: "09d.png"},
|
||||||
|
{ID: 311, Meaning: "drizzle rain", Icon1: "09d.png"},
|
||||||
|
{ID: 312, Meaning: "heavy intensity drizzle rain", Icon1: "09d.png"},
|
||||||
|
{ID: 313, Meaning: "shower rain and drizzle", Icon1: "09d.png"},
|
||||||
|
{ID: 314, Meaning: "heavy shower rain and drizzle", Icon1: "09d.png"},
|
||||||
|
{ID: 321, Meaning: "shower drizzle", Icon1: "09d.png"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// RainConditions is a slice of ConditionData pointers
|
||||||
|
var RainConditions = []*ConditionData{
|
||||||
|
{ID: 500, Meaning: "light rain", Icon1: "09d.png"},
|
||||||
|
{ID: 501, Meaning: "moderate rain", Icon1: "09d.png"},
|
||||||
|
{ID: 502, Meaning: "heavy intensity rain", Icon1: "09d.png"},
|
||||||
|
{ID: 503, Meaning: "very heavy rain", Icon1: "09d.png"},
|
||||||
|
{ID: 504, Meaning: "extreme rain", Icon1: "09d.png"},
|
||||||
|
{ID: 511, Meaning: "freezing rain", Icon1: "13d.png"},
|
||||||
|
{ID: 520, Meaning: "light intensity shower rain", Icon1: "09d.png"},
|
||||||
|
{ID: 521, Meaning: "shower rain", Icon1: "09d.png"},
|
||||||
|
{ID: 522, Meaning: "heavy intensity shower rain", Icon1: "09d.png"},
|
||||||
|
{ID: 531, Meaning: "ragged shower rain", Icon1: "09d.png"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// SnowConditions is a slice of ConditionData pointers
|
||||||
|
var SnowConditions = []*ConditionData{
|
||||||
|
{ID: 600, Meaning: "light snow", Icon1: "13d.png"},
|
||||||
|
{ID: 601, Meaning: "snow", Icon1: "13d.png"},
|
||||||
|
{ID: 602, Meaning: "heavy snow", Icon1: "13d.png"},
|
||||||
|
{ID: 611, Meaning: "sleet", Icon1: "13d.png"},
|
||||||
|
{ID: 612, Meaning: "shower sleet", Icon1: "13d.png"},
|
||||||
|
{ID: 615, Meaning: "light rain and snow", Icon1: "13d.png"},
|
||||||
|
{ID: 616, Meaning: "rain and snow", Icon1: "13d.png"},
|
||||||
|
{ID: 620, Meaning: "light shower snow", Icon1: "13d.png"},
|
||||||
|
{ID: 621, Meaning: "shower snow", Icon1: "13d.png"},
|
||||||
|
{ID: 622, Meaning: "heavy shower snow", Icon1: "13d.png"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// AtmosphereConditions is a slice of ConditionData pointers
|
||||||
|
var AtmosphereConditions = []*ConditionData{
|
||||||
|
{ID: 701, Meaning: "mist", Icon1: "50d.png"},
|
||||||
|
{ID: 711, Meaning: "smoke", Icon1: "50d.png"},
|
||||||
|
{ID: 721, Meaning: "haze", Icon1: "50d.png"},
|
||||||
|
{ID: 731, Meaning: "sand, dust whirls", Icon1: "50d.png"},
|
||||||
|
{ID: 741, Meaning: "fog", Icon1: "50d.png"},
|
||||||
|
{ID: 751, Meaning: "sand", Icon1: "50d.png"},
|
||||||
|
{ID: 761, Meaning: "dust", Icon1: "50d.png"},
|
||||||
|
{ID: 762, Meaning: "volcanic ash", Icon1: "50d.png"},
|
||||||
|
{ID: 771, Meaning: "squalls", Icon1: "50d.png"},
|
||||||
|
{ID: 781, Meaning: "tornado", Icon1: "50d.png"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// CloudConditions is a slice of ConditionData pointers
|
||||||
|
var CloudConditions = []*ConditionData{
|
||||||
|
{ID: 800, Meaning: "clear sky", Icon1: "01d.png", Icon2: "01n.png"},
|
||||||
|
{ID: 801, Meaning: "few clouds", Icon1: "02d.png", Icon2: " 02n.png"},
|
||||||
|
{ID: 802, Meaning: "scattered clouds", Icon1: "03d.png", Icon2: "03d.png"},
|
||||||
|
{ID: 803, Meaning: "broken clouds", Icon1: "04d.png", Icon2: "03d.png"},
|
||||||
|
{ID: 804, Meaning: "overcast clouds", Icon1: "04d.png", Icon2: "04d.png"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExtremeConditions is a slice of ConditionData pointers
|
||||||
|
var ExtremeConditions = []*ConditionData{
|
||||||
|
{ID: 900, Meaning: "tornado", Icon1: ""},
|
||||||
|
{ID: 901, Meaning: "tropical storm", Icon1: ""},
|
||||||
|
{ID: 902, Meaning: "hurricane", Icon1: ""},
|
||||||
|
{ID: 903, Meaning: "cold", Icon1: ""},
|
||||||
|
{ID: 904, Meaning: "hot", Icon1: ""},
|
||||||
|
{ID: 905, Meaning: "windy", Icon1: ""},
|
||||||
|
{ID: 906, Meaning: "hail", Icon1: ""},
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdditionalConditions is a slive of ConditionData pointers
|
||||||
|
var AdditionalConditions = []*ConditionData{
|
||||||
|
{ID: 951, Meaning: "calm", Icon1: ""},
|
||||||
|
{ID: 952, Meaning: "light breeze", Icon1: ""},
|
||||||
|
{ID: 953, Meaning: "gentle breeze", Icon1: ""},
|
||||||
|
{ID: 954, Meaning: "moderate breeze", Icon1: ""},
|
||||||
|
{ID: 955, Meaning: "fresh breeze", Icon1: ""},
|
||||||
|
{ID: 956, Meaning: "strong breeze", Icon1: ""},
|
||||||
|
{ID: 957, Meaning: "high wind, near gale", Icon1: ""},
|
||||||
|
{ID: 958, Meaning: "gale", Icon1: ""},
|
||||||
|
{ID: 959, Meaning: "severe gale", Icon1: ""},
|
||||||
|
{ID: 960, Meaning: "storm", Icon1: ""},
|
||||||
|
{ID: 961, Meaning: "violent storm", Icon1: ""},
|
||||||
|
{ID: 962, Meaning: "hurricane", Icon1: ""},
|
||||||
|
}
|
143
vendor/github.com/briandowns/openweathermap/current.go
generated
vendored
Normal file
143
vendor/github.com/briandowns/openweathermap/current.go
generated
vendored
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
// Copyright 2015 Brian J. Downs
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package openweathermap
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CurrentWeatherData struct contains an aggregate view of the structs
|
||||||
|
// defined above for JSON to be unmarshaled into.
|
||||||
|
type CurrentWeatherData struct {
|
||||||
|
GeoPos Coordinates `json:"coord"`
|
||||||
|
Sys Sys `json:"sys"`
|
||||||
|
Base string `json:"base"`
|
||||||
|
Weather []Weather `json:"weather"`
|
||||||
|
Main Main `json:"main"`
|
||||||
|
Wind Wind `json:"wind"`
|
||||||
|
Clouds Clouds `json:"clouds"`
|
||||||
|
Rain Rain `json:"rain"`
|
||||||
|
Snow Snow `json:"snow"`
|
||||||
|
Dt int `json:"dt"`
|
||||||
|
ID int `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Cod int `json:"cod"`
|
||||||
|
Unit string
|
||||||
|
Lang string
|
||||||
|
Key string
|
||||||
|
*Settings
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewCurrent returns a new CurrentWeatherData pointer with the supplied parameters
|
||||||
|
func NewCurrent(unit, lang, key string, options ...Option) (*CurrentWeatherData, error) {
|
||||||
|
unitChoice := strings.ToUpper(unit)
|
||||||
|
langChoice := strings.ToUpper(lang)
|
||||||
|
|
||||||
|
c := &CurrentWeatherData{
|
||||||
|
Settings: NewSettings(),
|
||||||
|
}
|
||||||
|
|
||||||
|
if ValidDataUnit(unitChoice) {
|
||||||
|
c.Unit = DataUnits[unitChoice]
|
||||||
|
} else {
|
||||||
|
return nil, errUnitUnavailable
|
||||||
|
}
|
||||||
|
|
||||||
|
if ValidLangCode(langChoice) {
|
||||||
|
c.Lang = langChoice
|
||||||
|
} else {
|
||||||
|
return nil, errLangUnavailable
|
||||||
|
}
|
||||||
|
var err error
|
||||||
|
c.Key, err = setKey(key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := setOptions(c.Settings, options); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return c, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CurrentByName will provide the current weather with the provided
|
||||||
|
// location name.
|
||||||
|
func (w *CurrentWeatherData) CurrentByName(location string) error {
|
||||||
|
response, err := w.client.Get(fmt.Sprintf(fmt.Sprintf(baseURL, "appid=%s&q=%s&units=%s&lang=%s"), w.Key, url.QueryEscape(location), w.Unit, w.Lang))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
|
|
||||||
|
if err := json.NewDecoder(response.Body).Decode(&w); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CurrentByCoordinates will provide the current weather with the
|
||||||
|
// provided location coordinates.
|
||||||
|
func (w *CurrentWeatherData) CurrentByCoordinates(location *Coordinates) error {
|
||||||
|
response, err := w.client.Get(fmt.Sprintf(fmt.Sprintf(baseURL, "appid=%s&lat=%f&lon=%f&units=%s&lang=%s"), w.Key, location.Latitude, location.Longitude, w.Unit, w.Lang))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
|
|
||||||
|
if err = json.NewDecoder(response.Body).Decode(&w); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CurrentByID will provide the current weather with the
|
||||||
|
// provided location ID.
|
||||||
|
func (w *CurrentWeatherData) CurrentByID(id int) error {
|
||||||
|
response, err := w.client.Get(fmt.Sprintf(fmt.Sprintf(baseURL, "appid=%s&id=%d&units=%s&lang=%s"), w.Key, id, w.Unit, w.Lang))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
|
|
||||||
|
if err = json.NewDecoder(response.Body).Decode(&w); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CurrentByZip will provide the current weather for the
|
||||||
|
// provided zip code.
|
||||||
|
func (w *CurrentWeatherData) CurrentByZip(zip int, countryCode string) error {
|
||||||
|
response, err := w.client.Get(fmt.Sprintf(fmt.Sprintf(baseURL, "appid=%s&zip=%d,%s&units=%s&lang=%s"), w.Key, zip, countryCode, w.Unit, w.Lang))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
|
if err = json.NewDecoder(response.Body).Decode(&w); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CurrentByArea will provide the current weather for the
|
||||||
|
// provided area.
|
||||||
|
func (w *CurrentWeatherData) CurrentByArea() {}
|
18
vendor/github.com/briandowns/openweathermap/doc.go
generated
vendored
Normal file
18
vendor/github.com/briandowns/openweathermap/doc.go
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright 2015 Brian J. Downs
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// Package openweathermap is a library for use to access the
|
||||||
|
// http://openweathermap.org API. JSON is the only return format supported
|
||||||
|
// at this time.
|
||||||
|
package openweathermap
|
151
vendor/github.com/briandowns/openweathermap/forecast.go
generated
vendored
Normal file
151
vendor/github.com/briandowns/openweathermap/forecast.go
generated
vendored
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
// Copyright 2015 Brian J. Downs
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package openweathermap
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ForecastSys area population
|
||||||
|
type ForecastSys struct {
|
||||||
|
Population int `json:"population"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Temperature holds returned termperate sure stats
|
||||||
|
type Temperature struct {
|
||||||
|
Day float64 `json:"day"`
|
||||||
|
Min float64 `json:"min"`
|
||||||
|
Max float64 `json:"max"`
|
||||||
|
Night float64 `json:"night"`
|
||||||
|
Eve float64 `json:"eve"`
|
||||||
|
Morn float64 `json:"morn"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// City data for given location
|
||||||
|
type City struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Coord Coordinates `json:"coord"`
|
||||||
|
Country string `json:"country"`
|
||||||
|
Population int `json:"population"`
|
||||||
|
Sys ForecastSys `json:"sys"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ForecastWeather interface {
|
||||||
|
DailyByName(location string, days int) error
|
||||||
|
DailyByCoordinates(location *Coordinates, days int) error
|
||||||
|
DailyByID(id, days int) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// json served by OWM API can take different forms, so all of them must be matched
|
||||||
|
// by corresponding data type and unmarshall method
|
||||||
|
type ForecastWeatherJson interface {
|
||||||
|
Decode(r io.Reader) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type ForecastWeatherData struct {
|
||||||
|
Unit string
|
||||||
|
Lang string
|
||||||
|
Key string
|
||||||
|
baseURL string
|
||||||
|
*Settings
|
||||||
|
ForecastWeatherJson
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewForecast returns a new HistoricalWeatherData pointer with
|
||||||
|
// the supplied arguments.
|
||||||
|
func NewForecast(forecastType, unit, lang, key string, options ...Option) (*ForecastWeatherData, error) {
|
||||||
|
unitChoice := strings.ToUpper(unit)
|
||||||
|
langChoice := strings.ToUpper(lang)
|
||||||
|
|
||||||
|
if forecastType != "16" && forecastType != "5" {
|
||||||
|
return nil, errForecastUnavailable
|
||||||
|
}
|
||||||
|
|
||||||
|
if !ValidDataUnit(unitChoice) {
|
||||||
|
return nil, errUnitUnavailable
|
||||||
|
}
|
||||||
|
|
||||||
|
if !ValidLangCode(langChoice) {
|
||||||
|
return nil, errLangUnavailable
|
||||||
|
}
|
||||||
|
|
||||||
|
settings := NewSettings()
|
||||||
|
if err := setOptions(settings, options); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
k, err := setKey(key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
forecastData := ForecastWeatherData{
|
||||||
|
Unit: DataUnits[unitChoice],
|
||||||
|
Lang: langChoice,
|
||||||
|
Key: k,
|
||||||
|
Settings: settings,
|
||||||
|
}
|
||||||
|
|
||||||
|
if forecastType == "16" {
|
||||||
|
forecastData.baseURL = forecast16Base
|
||||||
|
forecastData.ForecastWeatherJson = &Forecast16WeatherData{}
|
||||||
|
} else {
|
||||||
|
forecastData.baseURL = forecast5Base
|
||||||
|
forecastData.ForecastWeatherJson = &Forecast5WeatherData{}
|
||||||
|
}
|
||||||
|
|
||||||
|
return &forecastData, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DailyByName will provide a forecast for the location given for the
|
||||||
|
// number of days given.
|
||||||
|
func (f *ForecastWeatherData) DailyByName(location string, days int) error {
|
||||||
|
response, err := f.client.Get(fmt.Sprintf(f.baseURL, f.Key, fmt.Sprintf("%s=%s", "q", url.QueryEscape(location)), f.Unit, f.Lang, days))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
|
|
||||||
|
return f.ForecastWeatherJson.Decode(response.Body)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DailyByCoordinates will provide a forecast for the coordinates ID give
|
||||||
|
// for the number of days given.
|
||||||
|
func (f *ForecastWeatherData) DailyByCoordinates(location *Coordinates, days int) error {
|
||||||
|
response, err := f.client.Get(fmt.Sprintf(f.baseURL, f.Key, fmt.Sprintf("lat=%f&lon=%f", location.Latitude, location.Longitude), f.Unit, f.Lang, days))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
|
|
||||||
|
return f.ForecastWeatherJson.Decode(response.Body)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DailyByID will provide a forecast for the location ID give for the
|
||||||
|
// number of days given.
|
||||||
|
func (f *ForecastWeatherData) DailyByID(id, days int) error {
|
||||||
|
response, err := f.client.Get(fmt.Sprintf(f.baseURL, f.Key, fmt.Sprintf("%s=%s", "id", strconv.Itoa(id)), f.Unit, f.Lang, days))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
|
|
||||||
|
return f.ForecastWeatherJson.Decode(response.Body)
|
||||||
|
}
|
36
vendor/github.com/briandowns/openweathermap/forecast16.go
generated
vendored
Normal file
36
vendor/github.com/briandowns/openweathermap/forecast16.go
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package openweathermap
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Forecast16WeatherList holds specific query data
|
||||||
|
type Forecast16WeatherList struct {
|
||||||
|
Dt int `json:"dt"`
|
||||||
|
Temp Temperature `json:"temp"`
|
||||||
|
Pressure float64 `json:"pressure"`
|
||||||
|
Humidity int `json:"humidity"`
|
||||||
|
Weather []Weather `json:"weather"`
|
||||||
|
Speed float64 `json:"speed"`
|
||||||
|
Deg int `json:"deg"`
|
||||||
|
Clouds int `json:"clouds"`
|
||||||
|
Snow float64 `json:"snow"`
|
||||||
|
Rain float64 `json:"rain"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Forecast16WeatherData will hold returned data from queries
|
||||||
|
type Forecast16WeatherData struct {
|
||||||
|
COD int `json:"cod"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
City City `json:"city"`
|
||||||
|
Cnt int `json:"cnt"`
|
||||||
|
List []Forecast16WeatherList `json:"list"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *Forecast16WeatherData) Decode(r io.Reader) error {
|
||||||
|
if err := json.NewDecoder(r).Decode(&f); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
50
vendor/github.com/briandowns/openweathermap/forecast5.go
generated
vendored
Normal file
50
vendor/github.com/briandowns/openweathermap/forecast5.go
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
package openweathermap
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"io"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DtTxt struct {
|
||||||
|
time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dt *DtTxt) UnmarshalJSON(b []byte) error {
|
||||||
|
t, err := time.Parse("2006-01-02 15:04:05", strings.Trim(string(b), "\""))
|
||||||
|
dt.Time = t
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *DtTxt) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(t)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Forecast5WeatherList holds specific query data
|
||||||
|
type Forecast5WeatherList struct {
|
||||||
|
Dt int `json:"dt"`
|
||||||
|
Main Main `json:"main"`
|
||||||
|
Weather []Weather `json:"weather"`
|
||||||
|
Clouds Clouds `json:"clouds"`
|
||||||
|
Wind Wind `json:"wind"`
|
||||||
|
Rain Rain `json:"rain"`
|
||||||
|
Snow Snow `json:"snow"`
|
||||||
|
DtTxt DtTxt `json:"dt_txt"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Forecast5WeatherData will hold returned data from queries
|
||||||
|
type Forecast5WeatherData struct {
|
||||||
|
// COD string `json:"cod"`
|
||||||
|
// Message float64 `json:"message"`
|
||||||
|
City City `json:"city"`
|
||||||
|
Cnt int `json:"cnt"`
|
||||||
|
List []Forecast5WeatherList `json:"list"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *Forecast5WeatherData) Decode(r io.Reader) error {
|
||||||
|
if err := json.NewDecoder(r).Decode(&f); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
147
vendor/github.com/briandowns/openweathermap/history.go
generated
vendored
Normal file
147
vendor/github.com/briandowns/openweathermap/history.go
generated
vendored
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
// Copyright 2015 Brian J. Downs
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package openweathermap
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// HistoricalParameters struct holds the (optional) fields to be
|
||||||
|
// supplied for historical data requests.
|
||||||
|
type HistoricalParameters struct {
|
||||||
|
Start int64 // Data start (unix time, UTC time zone)
|
||||||
|
End int64 // Data end (unix time, UTC time zone)
|
||||||
|
Cnt int // Amount of returned data (one per hour, can be used instead of Data end)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rain struct contains 3 hour data
|
||||||
|
type Rain struct {
|
||||||
|
ThreeH float64 `json:"3h"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Snow struct contains 3 hour data
|
||||||
|
type Snow struct {
|
||||||
|
ThreeH float64 `json:"3h"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// WeatherHistory struct contains aggregate fields from the above
|
||||||
|
// structs.
|
||||||
|
type WeatherHistory struct {
|
||||||
|
Main Main `json:"main"`
|
||||||
|
Wind Wind `json:"wind"`
|
||||||
|
Clouds Clouds `json:"clouds"`
|
||||||
|
Weather []Weather `json:"weather"`
|
||||||
|
Rain Rain `json:"rain"`
|
||||||
|
Dt int `json:"dt"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// HistoricalWeatherData struct is where the JSON is unmarshaled to
|
||||||
|
// when receiving data for a historical request.
|
||||||
|
type HistoricalWeatherData struct {
|
||||||
|
Message string `json:"message"`
|
||||||
|
Cod int `json:"cod"`
|
||||||
|
CityData int `json:"city_data"`
|
||||||
|
CalcTime float64 `json:"calctime"`
|
||||||
|
Cnt int `json:"cnt"`
|
||||||
|
List []WeatherHistory `json:"list"`
|
||||||
|
Unit string
|
||||||
|
Key string
|
||||||
|
*Settings
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewHistorical returns a new HistoricalWeatherData pointer with
|
||||||
|
//the supplied arguments.
|
||||||
|
func NewHistorical(unit, key string, options ...Option) (*HistoricalWeatherData, error) {
|
||||||
|
h := &HistoricalWeatherData{
|
||||||
|
Settings: NewSettings(),
|
||||||
|
}
|
||||||
|
|
||||||
|
unitChoice := strings.ToUpper(unit)
|
||||||
|
if !ValidDataUnit(unitChoice) {
|
||||||
|
return nil, errUnitUnavailable
|
||||||
|
}
|
||||||
|
h.Unit = DataUnits[unitChoice]
|
||||||
|
|
||||||
|
var err error
|
||||||
|
h.Key, err = setKey(key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := setOptions(h.Settings, options); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return h, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// HistoryByName will return the history for the provided location
|
||||||
|
func (h *HistoricalWeatherData) HistoryByName(location string) error {
|
||||||
|
response, err := h.client.Get(fmt.Sprintf(fmt.Sprintf(historyURL, "city?appid=%s&q=%s"), h.Key, url.QueryEscape(location)))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
|
|
||||||
|
if err = json.NewDecoder(response.Body).Decode(&h); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// HistoryByID will return the history for the provided location ID
|
||||||
|
func (h *HistoricalWeatherData) HistoryByID(id int, hp ...*HistoricalParameters) error {
|
||||||
|
if len(hp) > 0 {
|
||||||
|
response, err := h.client.Get(fmt.Sprintf(fmt.Sprintf(historyURL, "city?appid=%s&id=%d&type=hour&start%d&end=%d&cnt=%d"), h.Key, id, hp[0].Start, hp[0].End, hp[0].Cnt))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
|
|
||||||
|
if err = json.NewDecoder(response.Body).Decode(&h); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := h.client.Get(fmt.Sprintf(fmt.Sprintf(historyURL, "city?appid=%s&id=%d"), h.Key, id))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
|
|
||||||
|
if err = json.NewDecoder(response.Body).Decode(&h); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// HistoryByCoord will return the history for the provided coordinates
|
||||||
|
func (h *HistoricalWeatherData) HistoryByCoord(location *Coordinates, hp *HistoricalParameters) error {
|
||||||
|
response, err := h.client.Get(fmt.Sprintf(fmt.Sprintf(historyURL, "appid=%s&lat=%f&lon=%f&start=%d&end=%d"), h.Key, location.Latitude, location.Longitude, hp.Start, hp.End))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
|
|
||||||
|
if err = json.NewDecoder(response.Body).Decode(&h); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
228
vendor/github.com/briandowns/openweathermap/openweathermap.go
generated
vendored
Normal file
228
vendor/github.com/briandowns/openweathermap/openweathermap.go
generated
vendored
Normal file
@ -0,0 +1,228 @@
|
|||||||
|
// Copyright 2015 Brian J. Downs
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package openweathermap
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
var errUnitUnavailable = errors.New("unit unavailable")
|
||||||
|
var errLangUnavailable = errors.New("language unavailable")
|
||||||
|
var errInvalidKey = errors.New("invalid api key")
|
||||||
|
var errInvalidOption = errors.New("invalid option")
|
||||||
|
var errInvalidHttpClient = errors.New("invalid http client")
|
||||||
|
var errForecastUnavailable = errors.New("forecast unavailable")
|
||||||
|
|
||||||
|
// DataUnits represents the character chosen to represent the temperature notation
|
||||||
|
var DataUnits = map[string]string{"C": "metric", "F": "imperial", "K": "internal"}
|
||||||
|
var (
|
||||||
|
baseURL = "http://api.openweathermap.org/data/2.5/weather?%s"
|
||||||
|
iconURL = "http://openweathermap.org/img/w/%s"
|
||||||
|
stationURL = "http://api.openweathermap.org/data/2.5/station?id=%d"
|
||||||
|
forecast5Base = "http://api.openweathermap.org/data/2.5/forecast?appid=%s&%s&mode=json&units=%s&lang=%s&cnt=%d"
|
||||||
|
forecast16Base = "http://api.openweathermap.org/data/2.5/forecast/daily?appid=%s&%s&mode=json&units=%s&lang=%s&cnt=%d"
|
||||||
|
historyURL = "http://api.openweathermap.org/data/2.5/history/%s"
|
||||||
|
pollutionURL = "http://api.openweathermap.org/pollution/v1/co/"
|
||||||
|
uvURL = "http://api.openweathermap.org/data/2.5/"
|
||||||
|
dataPostURL = "http://openweathermap.org/data/post"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LangCodes holds all supported languages to be used
|
||||||
|
// inspried and sourced from @bambocher (github.com/bambocher)
|
||||||
|
var LangCodes = map[string]string{
|
||||||
|
"EN": "English",
|
||||||
|
"RU": "Russian",
|
||||||
|
"IT": "Italian",
|
||||||
|
"ES": "Spanish",
|
||||||
|
"SP": "Spanish",
|
||||||
|
"UK": "Ukrainian",
|
||||||
|
"UA": "Ukrainian",
|
||||||
|
"DE": "German",
|
||||||
|
"PT": "Portuguese",
|
||||||
|
"RO": "Romanian",
|
||||||
|
"PL": "Polish",
|
||||||
|
"FI": "Finnish",
|
||||||
|
"NL": "Dutch",
|
||||||
|
"FR": "French",
|
||||||
|
"BG": "Bulgarian",
|
||||||
|
"SV": "Swedish",
|
||||||
|
"SE": "Swedish",
|
||||||
|
"TR": "Turkish",
|
||||||
|
"HR": "Croatian",
|
||||||
|
"CA": "Catalan",
|
||||||
|
"ZH_TW": "Chinese Traditional",
|
||||||
|
"ZH": "Chinese Simplified",
|
||||||
|
"ZH_CN": "Chinese Simplified",
|
||||||
|
}
|
||||||
|
|
||||||
|
// Config will hold default settings to be passed into the
|
||||||
|
// "NewCurrent, NewForecast, etc}" functions.
|
||||||
|
type Config struct {
|
||||||
|
Mode string // user choice of JSON or XML
|
||||||
|
Unit string // measurement for results to be displayed. F, C, or K
|
||||||
|
Lang string // should reference a key in the LangCodes map
|
||||||
|
APIKey string // API Key for connecting to the OWM
|
||||||
|
Username string // Username for posting data
|
||||||
|
Password string // Pasword for posting data
|
||||||
|
}
|
||||||
|
|
||||||
|
// APIError returned on failed API calls.
|
||||||
|
type APIError struct {
|
||||||
|
Message string `json:"message"`
|
||||||
|
COD string `json:"cod"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Coordinates struct holds longitude and latitude data in returned
|
||||||
|
// JSON or as parameter data for requests using longitude and latitude.
|
||||||
|
type Coordinates struct {
|
||||||
|
Longitude float64 `json:"lon"`
|
||||||
|
Latitude float64 `json:"lat"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sys struct contains general information about the request
|
||||||
|
// and the surrounding area for where the request was made.
|
||||||
|
type Sys struct {
|
||||||
|
Type int `json:"type"`
|
||||||
|
ID int `json:"id"`
|
||||||
|
Message float64 `json:"message"`
|
||||||
|
Country string `json:"country"`
|
||||||
|
Sunrise int `json:"sunrise"`
|
||||||
|
Sunset int `json:"sunset"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wind struct contains the speed and degree of the wind.
|
||||||
|
type Wind struct {
|
||||||
|
Speed float64 `json:"speed"`
|
||||||
|
Deg float64 `json:"deg"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Weather struct holds high-level, basic info on the returned
|
||||||
|
// data.
|
||||||
|
type Weather struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
Main string `json:"main"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
Icon string `json:"icon"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main struct contains the temperates, humidity, pressure for the request.
|
||||||
|
type Main struct {
|
||||||
|
Temp float64 `json:"temp"`
|
||||||
|
TempMin float64 `json:"temp_min"`
|
||||||
|
TempMax float64 `json:"temp_max"`
|
||||||
|
Pressure float64 `json:"pressure"`
|
||||||
|
SeaLevel float64 `json:"sea_level"`
|
||||||
|
GrndLevel float64 `json:"grnd_level"`
|
||||||
|
Humidity int `json:"humidity"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clouds struct holds data regarding cloud cover.
|
||||||
|
type Clouds struct {
|
||||||
|
All int `json:"all"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// return key
|
||||||
|
// }
|
||||||
|
func setKey(key string) (string, error) {
|
||||||
|
if err := ValidAPIKey(key); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return key, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidDataUnit makes sure the string passed in is an accepted
|
||||||
|
// unit of measure to be used for the return data.
|
||||||
|
func ValidDataUnit(u string) bool {
|
||||||
|
for d := range DataUnits {
|
||||||
|
if u == d {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidLangCode makes sure the string passed in is an
|
||||||
|
// acceptable lang code.
|
||||||
|
func ValidLangCode(c string) bool {
|
||||||
|
for d := range LangCodes {
|
||||||
|
if c == d {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidDataUnitSymbol makes sure the string passed in is an
|
||||||
|
// acceptable data unit symbol.
|
||||||
|
func ValidDataUnitSymbol(u string) bool {
|
||||||
|
for _, d := range DataUnits {
|
||||||
|
if u == d {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidAPIKey makes sure that the key given is a valid one
|
||||||
|
func ValidAPIKey(key string) error {
|
||||||
|
if len(key) != 32 {
|
||||||
|
return errors.New("invalid key")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckAPIKeyExists will see if an API key has been set.
|
||||||
|
func (c *Config) CheckAPIKeyExists() bool { return len(c.APIKey) > 1 }
|
||||||
|
|
||||||
|
// Settings holds the client settings
|
||||||
|
type Settings struct {
|
||||||
|
client *http.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSettings returns a new Setting pointer with default http client.
|
||||||
|
func NewSettings() *Settings {
|
||||||
|
return &Settings{
|
||||||
|
client: http.DefaultClient,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Optional client settings
|
||||||
|
type Option func(s *Settings) error
|
||||||
|
|
||||||
|
// WithHttpClient sets custom http client when creating a new Client.
|
||||||
|
func WithHttpClient(c *http.Client) Option {
|
||||||
|
return func(s *Settings) error {
|
||||||
|
if c == nil {
|
||||||
|
return errInvalidHttpClient
|
||||||
|
}
|
||||||
|
s.client = c
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// setOptions sets Optional client settings to the Settings pointer
|
||||||
|
func setOptions(settings *Settings, options []Option) error {
|
||||||
|
for _, option := range options {
|
||||||
|
if option == nil {
|
||||||
|
return errInvalidOption
|
||||||
|
}
|
||||||
|
err := option(settings)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
82
vendor/github.com/briandowns/openweathermap/pollution.go
generated
vendored
Normal file
82
vendor/github.com/briandowns/openweathermap/pollution.go
generated
vendored
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
package openweathermap
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DateTimeAliases holds the alias the pollution API supports in lieu
|
||||||
|
// of an ISO 8601 timestamp
|
||||||
|
var DateTimeAliases = []string{"current"}
|
||||||
|
|
||||||
|
// ValidAlias checks to make sure the given alias is a valid one
|
||||||
|
func ValidAlias(alias string) bool {
|
||||||
|
for _, i := range DateTimeAliases {
|
||||||
|
if i == alias {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// PollutionData holds the pollution specific data from the call
|
||||||
|
type PollutionData struct {
|
||||||
|
Precision float64 `json:"precision"`
|
||||||
|
Pressure float64 `json:"pressure"`
|
||||||
|
Value float64 `json:"value"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PollutionParameters holds the parameters needed to make
|
||||||
|
// a call to the pollution API
|
||||||
|
type PollutionParameters struct {
|
||||||
|
Location Coordinates
|
||||||
|
Datetime string // this should be either ISO 8601 or an alias
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pollution holds the data returnd from the pollution API
|
||||||
|
type Pollution struct {
|
||||||
|
Time string `json:"time"`
|
||||||
|
Location Coordinates `json:"location"`
|
||||||
|
Data []PollutionData `json:"data"`
|
||||||
|
Key string
|
||||||
|
*Settings
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewPollution creates a new reference to Pollution
|
||||||
|
func NewPollution(key string, options ...Option) (*Pollution, error) {
|
||||||
|
k, err := setKey(key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
p := &Pollution{
|
||||||
|
Key: k,
|
||||||
|
Settings: NewSettings(),
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := setOptions(p.Settings, options); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return p, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// PollutionByParams gets the pollution data based on the given parameters
|
||||||
|
func (p *Pollution) PollutionByParams(params *PollutionParameters) error {
|
||||||
|
url := fmt.Sprintf("%s%s,%s/%s.json?appid=%s",
|
||||||
|
pollutionURL,
|
||||||
|
strconv.FormatFloat(params.Location.Latitude, 'f', -1, 64),
|
||||||
|
strconv.FormatFloat(params.Location.Longitude, 'f', -1, 64),
|
||||||
|
params.Datetime,
|
||||||
|
p.Key)
|
||||||
|
response, err := p.client.Get(url)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
|
|
||||||
|
if err = json.NewDecoder(response.Body).Decode(&p); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
80
vendor/github.com/briandowns/openweathermap/station.go
generated
vendored
Normal file
80
vendor/github.com/briandowns/openweathermap/station.go
generated
vendored
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
// Copyright 2015 Brian J. Downs
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package openweathermap
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Slice of type string of the valid parameters to be sent from a station.
|
||||||
|
// The API refers to this data as the "Weather station data transmission protocol"
|
||||||
|
var StationDataParameters = []string{
|
||||||
|
"wind_dir", // Wind direction
|
||||||
|
"wind_speed", // Wind speed
|
||||||
|
"wind_gust", // Wind gust speed
|
||||||
|
"temp", // Temperature
|
||||||
|
"humidity", // Relative humidty
|
||||||
|
"pressure", // Atmospheric pressure
|
||||||
|
"rain_1h", // Rain in the last hour
|
||||||
|
"rain_24h", // Rain in the last 24 hours
|
||||||
|
"rain_today", // Rain since midnight
|
||||||
|
"snow", // Snow in the last 24 hours
|
||||||
|
"lum", // Brightness
|
||||||
|
"lat", // Latitude
|
||||||
|
"long", // Longitude
|
||||||
|
"alt", // Altitude
|
||||||
|
"radiation", // Radiation
|
||||||
|
"dewpoint", // Dew point
|
||||||
|
"uv", // UV index
|
||||||
|
"name", // Weather station name
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidateStationDataParameter will make sure that whatever parameter
|
||||||
|
// supplied is one that can actually be used in the POST request.
|
||||||
|
func ValidateStationDataParameter(param string) bool {
|
||||||
|
for _, p := range StationDataParameters {
|
||||||
|
if param == p {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConvertToURLValues will convert a map to a url.Values instance. We're
|
||||||
|
// taking a map[string]string instead of something more type specific since
|
||||||
|
// the url.Values instance only takes strings to create the URL values.
|
||||||
|
func ConvertToURLValues(data map[string]string) string {
|
||||||
|
v := url.Values{}
|
||||||
|
|
||||||
|
for key, val := range data {
|
||||||
|
v.Set(key, val)
|
||||||
|
}
|
||||||
|
|
||||||
|
return v.Encode()
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendStationData will send an instance the provided url.Values to the
|
||||||
|
// provided URL.
|
||||||
|
func SendStationData(data url.Values) {
|
||||||
|
resp, err := http.PostForm(dataPostURL, data)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(resp.Body)
|
||||||
|
}
|
170
vendor/github.com/briandowns/openweathermap/uv.go
generated
vendored
Normal file
170
vendor/github.com/briandowns/openweathermap/uv.go
generated
vendored
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
package openweathermap
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var errInvalidUVIndex = errors.New("invalid UV index value")
|
||||||
|
|
||||||
|
// UVDataPoints holds the UV specific data
|
||||||
|
type UVDataPoints struct {
|
||||||
|
DT int64 `json:"dt"`
|
||||||
|
Value float64 `json:"value"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UV contains the response from the OWM UV API
|
||||||
|
type UV struct {
|
||||||
|
Coord []float64 `json:"coord"`
|
||||||
|
Data []UVDataPoints `json:"data,omitempty"`
|
||||||
|
/*Data []struct {
|
||||||
|
DT int64 `json:"dt"`
|
||||||
|
Value float64 `json:"value"`
|
||||||
|
} `json:"data,omitempty"`*/
|
||||||
|
DT int64 `json:"dt,omitempty"`
|
||||||
|
Value float64 `json:"value,omitempty"`
|
||||||
|
Key string
|
||||||
|
*Settings
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewUV creates a new reference to UV
|
||||||
|
func NewUV(key string, options ...Option) (*UV, error) {
|
||||||
|
k, err := setKey(key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
u := &UV{
|
||||||
|
Key: k,
|
||||||
|
Settings: NewSettings(),
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := setOptions(u.Settings, options); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return u, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Current gets the current UV data for the given coordinates
|
||||||
|
func (u *UV) Current(coord *Coordinates) error {
|
||||||
|
response, err := u.client.Get(fmt.Sprintf("%suvi?lat=%f&lon=%f&appid=%s", uvURL, coord.Latitude, coord.Longitude, u.Key))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
|
|
||||||
|
if err = json.NewDecoder(response.Body).Decode(&u); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Historical gets the historical UV data for the coordinates and times
|
||||||
|
func (u *UV) Historical(coord *Coordinates, start, end time.Time) error {
|
||||||
|
response, err := u.client.Get(fmt.Sprintf("%shistory?lat=%f&lon=%f&start=%d&end=%d&appid=%s", uvURL, coord.Latitude, coord.Longitude, start.Unix(), end.Unix(), u.Key))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
|
|
||||||
|
if err = json.NewDecoder(response.Body).Decode(&u); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UVIndexInfo
|
||||||
|
type UVIndexInfo struct {
|
||||||
|
// UVIndex holds the range of the index
|
||||||
|
UVIndex []float64
|
||||||
|
|
||||||
|
// MGC represents the Media graphic color
|
||||||
|
MGC string
|
||||||
|
|
||||||
|
// Risk of harm from unprotected sun exposure, for the average adult
|
||||||
|
Risk string
|
||||||
|
|
||||||
|
// RecommendedProtection contains information on what a person should
|
||||||
|
// do when outside in the associated UVIndex
|
||||||
|
RecommendedProtection string
|
||||||
|
}
|
||||||
|
|
||||||
|
// UVData contains data in regards to UV index ranges, rankings, and steps for protection
|
||||||
|
var UVData = []UVIndexInfo{
|
||||||
|
{
|
||||||
|
UVIndex: []float64{0, 2.9},
|
||||||
|
MGC: "Green",
|
||||||
|
Risk: "Low",
|
||||||
|
RecommendedProtection: "Wear sunglasses on bright days; use sunscreen if there is snow on the ground, which reflects UV radiation, or if you have particularly fair skin.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
UVIndex: []float64{3, 5.9},
|
||||||
|
MGC: "Yellow",
|
||||||
|
Risk: "Moderate",
|
||||||
|
RecommendedProtection: "Take precautions, such as covering up, if you will be outside. Stay in shade near midday when the sun is strongest.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
UVIndex: []float64{6, 7.9},
|
||||||
|
MGC: "Orange",
|
||||||
|
Risk: "High",
|
||||||
|
RecommendedProtection: "Cover the body with sun protective clothing, use SPF 30+ sunscreen, wear a hat, reduce time in the sun within three hours of solar noon, and wear sunglasses.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
UVIndex: []float64{8, 10.9},
|
||||||
|
MGC: "Red",
|
||||||
|
Risk: "Very high",
|
||||||
|
RecommendedProtection: "Wear SPF 30+ sunscreen, a shirt, sunglasses, and a wide-brimmed hat. Do not stay in the sun for too long.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
UVIndex: []float64{11},
|
||||||
|
MGC: "Violet",
|
||||||
|
Risk: "Extreme",
|
||||||
|
RecommendedProtection: "Take all precautions: Wear SPF 30+ sunscreen, a long-sleeved shirt and trousers, sunglasses, and a very broad hat. Avoid the sun within three hours of solar noon.",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// UVInformation provides information on the given UV data which includes the severity
|
||||||
|
// and "Recommended protection"
|
||||||
|
func (u *UV) UVInformation() ([]UVIndexInfo, error) {
|
||||||
|
switch {
|
||||||
|
case u.Value != 0:
|
||||||
|
switch {
|
||||||
|
case u.Value < 2.9:
|
||||||
|
return []UVIndexInfo{UVData[0]}, nil
|
||||||
|
case u.Value > 3 && u.Value < 5.9:
|
||||||
|
return []UVIndexInfo{UVData[1]}, nil
|
||||||
|
case u.Value > 6 && u.Value < 7.9:
|
||||||
|
return []UVIndexInfo{UVData[2]}, nil
|
||||||
|
case u.Value > 8 && u.Value < 10.9:
|
||||||
|
return []UVIndexInfo{UVData[3]}, nil
|
||||||
|
case u.Value >= 11:
|
||||||
|
return []UVIndexInfo{UVData[4]}, nil
|
||||||
|
default:
|
||||||
|
return nil, errInvalidUVIndex
|
||||||
|
}
|
||||||
|
|
||||||
|
case len(u.Data) > 0:
|
||||||
|
var uvi []UVIndexInfo
|
||||||
|
for _, i := range u.Data {
|
||||||
|
switch {
|
||||||
|
case i.Value < 2.9:
|
||||||
|
uvi = append(uvi, UVData[0])
|
||||||
|
case i.Value > 3 && u.Value < 5.9:
|
||||||
|
uvi = append(uvi, UVData[1])
|
||||||
|
case i.Value > 6 && u.Value < 7.9:
|
||||||
|
uvi = append(uvi, UVData[2])
|
||||||
|
case i.Value > 8 && u.Value < 10.9:
|
||||||
|
uvi = append(uvi, UVData[3])
|
||||||
|
case i.Value >= 11:
|
||||||
|
uvi = append(uvi, UVData[4])
|
||||||
|
default:
|
||||||
|
return nil, errInvalidUVIndex
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, nil
|
||||||
|
}
|
13
vendor/github.com/gdamore/encoding/.appveyor.yml
generated
vendored
Normal file
13
vendor/github.com/gdamore/encoding/.appveyor.yml
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
version: 1.0.{build}
|
||||||
|
clone_folder: c:\gopath\src\github.com\gdamore\encoding
|
||||||
|
environment:
|
||||||
|
GOPATH: c:\gopath
|
||||||
|
build_script:
|
||||||
|
- go version
|
||||||
|
- go env
|
||||||
|
- SET PATH=%LOCALAPPDATA%\atom\bin;%GOPATH%\bin;%PATH%
|
||||||
|
- go get -t ./...
|
||||||
|
- go build
|
||||||
|
- go install ./...
|
||||||
|
test_script:
|
||||||
|
- go test ./...
|
6
vendor/github.com/gdamore/encoding/.travis.yml
generated
vendored
Normal file
6
vendor/github.com/gdamore/encoding/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
language: go
|
||||||
|
|
||||||
|
go:
|
||||||
|
- 1.3
|
||||||
|
- 1.5
|
||||||
|
- tip
|
202
vendor/github.com/gdamore/encoding/LICENSE
generated
vendored
Normal file
202
vendor/github.com/gdamore/encoding/LICENSE
generated
vendored
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
19
vendor/github.com/gdamore/encoding/README.md
generated
vendored
Normal file
19
vendor/github.com/gdamore/encoding/README.md
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
## encoding
|
||||||
|
|
||||||
|
[](https://travis-ci.org/gdamore/encoding)
|
||||||
|
[](https://ci.appveyor.com/project/gdamore/encoding)
|
||||||
|
[](https://github.com/gdamore/encoding/blob/master/LICENSE)
|
||||||
|
[](https://godoc.org/github.com/gdamore/encoding)
|
||||||
|
[](http://goreportcard.com/report/gdamore/encoding)
|
||||||
|
|
||||||
|
Package encoding provides a number of encodings that are missing from the
|
||||||
|
standard Go [encoding]("https://godoc.org/golang.org/x/text/encoding") package.
|
||||||
|
|
||||||
|
We hope that we can contribute these to the standard Go library someday. It
|
||||||
|
turns out that some of these are useful for dealing with I/O streams coming
|
||||||
|
from non-UTF friendly sources.
|
||||||
|
|
||||||
|
The UTF8 Encoder is also useful for situations where valid UTF-8 might be
|
||||||
|
carried in streams that contain non-valid UTF; in particular I use it for
|
||||||
|
helping me cope with terminals that embed escape sequences in otherwise
|
||||||
|
valid UTF-8.
|
36
vendor/github.com/gdamore/encoding/ascii.go
generated
vendored
Normal file
36
vendor/github.com/gdamore/encoding/ascii.go
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// Copyright 2015 Garrett D'Amore
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the license at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package encoding
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golang.org/x/text/encoding"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ASCII represents the 7-bit US-ASCII scheme. It decodes directly to
|
||||||
|
// UTF-8 without change, as all ASCII values are legal UTF-8.
|
||||||
|
// Unicode values less than 128 (i.e. 7 bits) map 1:1 with ASCII.
|
||||||
|
// It encodes runes outside of that to 0x1A, the ASCII substitution character.
|
||||||
|
var ASCII encoding.Encoding
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
amap := make(map[byte]rune)
|
||||||
|
for i := 128; i <= 255; i++ {
|
||||||
|
amap[byte(i)] = RuneError
|
||||||
|
}
|
||||||
|
|
||||||
|
cm := &Charmap{Map: amap}
|
||||||
|
cm.Init()
|
||||||
|
ASCII = cm
|
||||||
|
}
|
192
vendor/github.com/gdamore/encoding/charmap.go
generated
vendored
Normal file
192
vendor/github.com/gdamore/encoding/charmap.go
generated
vendored
Normal file
@ -0,0 +1,192 @@
|
|||||||
|
// Copyright 2015 Garrett D'Amore
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the license at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package encoding
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
"unicode/utf8"
|
||||||
|
|
||||||
|
"golang.org/x/text/transform"
|
||||||
|
"golang.org/x/text/encoding"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// RuneError is an alias for the UTF-8 replacement rune, '\uFFFD'.
|
||||||
|
RuneError = '\uFFFD'
|
||||||
|
|
||||||
|
// RuneSelf is the rune below which UTF-8 and the Unicode values are
|
||||||
|
// identical. Its also the limit for ASCII.
|
||||||
|
RuneSelf = 0x80
|
||||||
|
|
||||||
|
// ASCIISub is the ASCII substitution character.
|
||||||
|
ASCIISub = '\x1a'
|
||||||
|
)
|
||||||
|
|
||||||
|
// Charmap is a structure for setting up encodings for 8-bit character sets,
|
||||||
|
// for transforming between UTF8 and that other character set. It has some
|
||||||
|
// ideas borrowed from golang.org/x/text/encoding/charmap, but it uses a
|
||||||
|
// different implementation. This implementation uses maps, and supports
|
||||||
|
// user-defined maps.
|
||||||
|
//
|
||||||
|
// We do assume that a character map has a reasonable substitution character,
|
||||||
|
// and that valid encodings are stable (exactly a 1:1 map) and stateless
|
||||||
|
// (that is there is no shift character or anything like that.) Hence this
|
||||||
|
// approach will not work for many East Asian character sets.
|
||||||
|
//
|
||||||
|
// Measurement shows little or no measurable difference in the performance of
|
||||||
|
// the two approaches. The difference was down to a couple of nsec/op, and
|
||||||
|
// no consistent pattern as to which ran faster. With the conversion to
|
||||||
|
// UTF-8 the code takes about 25 nsec/op. The conversion in the reverse
|
||||||
|
// direction takes about 100 nsec/op. (The larger cost for conversion
|
||||||
|
// from UTF-8 is most likely due to the need to convert the UTF-8 byte stream
|
||||||
|
// to a rune before conversion.
|
||||||
|
//
|
||||||
|
type Charmap struct {
|
||||||
|
transform.NopResetter
|
||||||
|
bytes map[rune]byte
|
||||||
|
runes [256][]byte
|
||||||
|
once sync.Once
|
||||||
|
|
||||||
|
// The map between bytes and runes. To indicate that a specific
|
||||||
|
// byte value is invalid for a charcter set, use the rune
|
||||||
|
// utf8.RuneError. Values that are absent from this map will
|
||||||
|
// be assumed to have the identity mapping -- that is the default
|
||||||
|
// is to assume ISO8859-1, where all 8-bit characters have the same
|
||||||
|
// numeric value as their Unicode runes. (Not to be confused with
|
||||||
|
// the UTF-8 values, which *will* be different for non-ASCII runes.)
|
||||||
|
//
|
||||||
|
// If no values less than RuneSelf are changed (or have non-identity
|
||||||
|
// mappings), then the character set is assumed to be an ASCII
|
||||||
|
// superset, and certain assumptions and optimizations become
|
||||||
|
// available for ASCII bytes.
|
||||||
|
Map map[byte]rune
|
||||||
|
|
||||||
|
// The ReplacementChar is the byte value to use for substitution.
|
||||||
|
// It should normally be ASCIISub for ASCII encodings. This may be
|
||||||
|
// unset (left to zero) for mappings that are strictly ASCII supersets.
|
||||||
|
// In that case ASCIISub will be assumed instead.
|
||||||
|
ReplacementChar byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type cmapDecoder struct {
|
||||||
|
transform.NopResetter
|
||||||
|
runes [256][]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type cmapEncoder struct {
|
||||||
|
transform.NopResetter
|
||||||
|
bytes map[rune]byte
|
||||||
|
replace byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// Init initializes internal values of a character map. This should
|
||||||
|
// be done early, to minimize the cost of allocation of transforms
|
||||||
|
// later. It is not strictly necessary however, as the allocation
|
||||||
|
// functions will arrange to call it if it has not already been done.
|
||||||
|
func (c *Charmap) Init() {
|
||||||
|
c.once.Do(c.initialize)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Charmap) initialize() {
|
||||||
|
c.bytes = make(map[rune]byte)
|
||||||
|
ascii := true
|
||||||
|
|
||||||
|
for i := 0; i < 256; i++ {
|
||||||
|
r, ok := c.Map[byte(i)]
|
||||||
|
if !ok {
|
||||||
|
r = rune(i)
|
||||||
|
}
|
||||||
|
if r < 128 && r != rune(i) {
|
||||||
|
ascii = false
|
||||||
|
}
|
||||||
|
if r != RuneError {
|
||||||
|
c.bytes[r] = byte(i)
|
||||||
|
}
|
||||||
|
utf := make([]byte, utf8.RuneLen(r))
|
||||||
|
utf8.EncodeRune(utf, r)
|
||||||
|
c.runes[i] = utf
|
||||||
|
}
|
||||||
|
if ascii && c.ReplacementChar == '\x00' {
|
||||||
|
c.ReplacementChar = ASCIISub
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewDecoder returns a Decoder the converts from the 8-bit
|
||||||
|
// character set to UTF-8. Unknown mappings, if any, are mapped
|
||||||
|
// to '\uFFFD'.
|
||||||
|
func (c *Charmap) NewDecoder() *encoding.Decoder {
|
||||||
|
c.Init()
|
||||||
|
return &encoding.Decoder{Transformer: &cmapDecoder{runes: c.runes}}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewEncoder returns a Transformer that converts from UTF8 to the
|
||||||
|
// 8-bit character set. Unknown mappings are mapped to 0x1A.
|
||||||
|
func (c *Charmap) NewEncoder() *encoding.Encoder {
|
||||||
|
c.Init()
|
||||||
|
return &encoding.Encoder{Transformer:
|
||||||
|
&cmapEncoder{bytes: c.bytes, replace: c.ReplacementChar}}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *cmapDecoder) Transform(dst, src []byte, atEOF bool) (int, int, error) {
|
||||||
|
var e error
|
||||||
|
var ndst, nsrc int
|
||||||
|
|
||||||
|
for _, c := range src {
|
||||||
|
b := d.runes[c]
|
||||||
|
l := len(b)
|
||||||
|
|
||||||
|
if ndst+l > len(dst) {
|
||||||
|
e = transform.ErrShortDst
|
||||||
|
break
|
||||||
|
}
|
||||||
|
for i := 0; i < l; i++ {
|
||||||
|
dst[ndst] = b[i]
|
||||||
|
ndst++
|
||||||
|
}
|
||||||
|
nsrc++
|
||||||
|
}
|
||||||
|
return ndst, nsrc, e
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *cmapEncoder) Transform(dst, src []byte, atEOF bool) (int, int, error) {
|
||||||
|
var e error
|
||||||
|
var ndst, nsrc int
|
||||||
|
for nsrc < len(src) {
|
||||||
|
if ndst >= len(dst) {
|
||||||
|
e = transform.ErrShortDst
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
r, sz := utf8.DecodeRune(src[nsrc:])
|
||||||
|
if r == utf8.RuneError && sz == 1 {
|
||||||
|
// If its inconclusive due to insufficient data in
|
||||||
|
// in the source, report it
|
||||||
|
if !atEOF && !utf8.FullRune(src[nsrc:]) {
|
||||||
|
e = transform.ErrShortSrc
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if c, ok := d.bytes[r]; ok {
|
||||||
|
dst[ndst] = c
|
||||||
|
} else {
|
||||||
|
dst[ndst] = d.replace
|
||||||
|
}
|
||||||
|
nsrc += sz
|
||||||
|
ndst++
|
||||||
|
}
|
||||||
|
|
||||||
|
return ndst, nsrc, e
|
||||||
|
}
|
17
vendor/github.com/gdamore/encoding/doc.go
generated
vendored
Normal file
17
vendor/github.com/gdamore/encoding/doc.go
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright 2015 Garrett D'Amore
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the license at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// Package encoding provides a few of the encoding structures that are
|
||||||
|
// missing from the Go x/text/encoding tree.
|
||||||
|
package encoding
|
273
vendor/github.com/gdamore/encoding/ebcdic.go
generated
vendored
Normal file
273
vendor/github.com/gdamore/encoding/ebcdic.go
generated
vendored
Normal file
@ -0,0 +1,273 @@
|
|||||||
|
// Copyright 2015 Garrett D'Amore
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the license at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package encoding
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golang.org/x/text/encoding"
|
||||||
|
)
|
||||||
|
|
||||||
|
// EBCDIC represents the 8-bit EBCDIC scheme, found in some mainframe
|
||||||
|
// environments. If you don't know what this is, consider yourself lucky.
|
||||||
|
var EBCDIC encoding.Encoding
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cm := &Charmap{
|
||||||
|
ReplacementChar: '\x3f',
|
||||||
|
Map: map[byte]rune{
|
||||||
|
// 0x00-0x03 match
|
||||||
|
0x04: RuneError,
|
||||||
|
0x05: '\t',
|
||||||
|
0x06: RuneError,
|
||||||
|
0x07: '\x7f',
|
||||||
|
0x08: RuneError,
|
||||||
|
0x09: RuneError,
|
||||||
|
0x0a: RuneError,
|
||||||
|
// 0x0b-0x13 match
|
||||||
|
0x14: RuneError,
|
||||||
|
0x15: '\x85', // Not in any ISO code
|
||||||
|
0x16: '\x08',
|
||||||
|
0x17: RuneError,
|
||||||
|
// 0x18-0x19 match
|
||||||
|
0x1a: RuneError,
|
||||||
|
0x1b: RuneError,
|
||||||
|
// 0x1c-0x1f match
|
||||||
|
0x20: RuneError,
|
||||||
|
0x21: RuneError,
|
||||||
|
0x22: RuneError,
|
||||||
|
0x23: RuneError,
|
||||||
|
0x24: RuneError,
|
||||||
|
0x25: '\n',
|
||||||
|
0x26: '\x17',
|
||||||
|
0x27: '\x1b',
|
||||||
|
0x28: RuneError,
|
||||||
|
0x29: RuneError,
|
||||||
|
0x2a: RuneError,
|
||||||
|
0x2b: RuneError,
|
||||||
|
0x2c: RuneError,
|
||||||
|
0x2d: '\x05',
|
||||||
|
0x2e: '\x06',
|
||||||
|
0x2f: '\x07',
|
||||||
|
0x30: RuneError,
|
||||||
|
0x31: RuneError,
|
||||||
|
0x32: '\x16',
|
||||||
|
0x33: RuneError,
|
||||||
|
0x34: RuneError,
|
||||||
|
0x35: RuneError,
|
||||||
|
0x36: RuneError,
|
||||||
|
0x37: '\x04',
|
||||||
|
0x38: RuneError,
|
||||||
|
0x39: RuneError,
|
||||||
|
0x3a: RuneError,
|
||||||
|
0x3b: RuneError,
|
||||||
|
0x3c: '\x14',
|
||||||
|
0x3d: '\x15',
|
||||||
|
0x3e: RuneError,
|
||||||
|
0x3f: '\x1a', // also replacement char
|
||||||
|
0x40: ' ',
|
||||||
|
0x41: '\xa0',
|
||||||
|
0x42: RuneError,
|
||||||
|
0x43: RuneError,
|
||||||
|
0x44: RuneError,
|
||||||
|
0x45: RuneError,
|
||||||
|
0x46: RuneError,
|
||||||
|
0x47: RuneError,
|
||||||
|
0x48: RuneError,
|
||||||
|
0x49: RuneError,
|
||||||
|
0x4a: RuneError,
|
||||||
|
0x4b: '.',
|
||||||
|
0x4c: '<',
|
||||||
|
0x4d: '(',
|
||||||
|
0x4e: '+',
|
||||||
|
0x4f: '|',
|
||||||
|
0x50: '&',
|
||||||
|
0x51: RuneError,
|
||||||
|
0x52: RuneError,
|
||||||
|
0x53: RuneError,
|
||||||
|
0x54: RuneError,
|
||||||
|
0x55: RuneError,
|
||||||
|
0x56: RuneError,
|
||||||
|
0x57: RuneError,
|
||||||
|
0x58: RuneError,
|
||||||
|
0x59: RuneError,
|
||||||
|
0x5a: '!',
|
||||||
|
0x5b: '$',
|
||||||
|
0x5c: '*',
|
||||||
|
0x5d: ')',
|
||||||
|
0x5e: ';',
|
||||||
|
0x5f: '¬',
|
||||||
|
0x60: '-',
|
||||||
|
0x61: '/',
|
||||||
|
0x62: RuneError,
|
||||||
|
0x63: RuneError,
|
||||||
|
0x64: RuneError,
|
||||||
|
0x65: RuneError,
|
||||||
|
0x66: RuneError,
|
||||||
|
0x67: RuneError,
|
||||||
|
0x68: RuneError,
|
||||||
|
0x69: RuneError,
|
||||||
|
0x6a: '¦',
|
||||||
|
0x6b: ',',
|
||||||
|
0x6c: '%',
|
||||||
|
0x6d: '_',
|
||||||
|
0x6e: '>',
|
||||||
|
0x6f: '?',
|
||||||
|
0x70: RuneError,
|
||||||
|
0x71: RuneError,
|
||||||
|
0x72: RuneError,
|
||||||
|
0x73: RuneError,
|
||||||
|
0x74: RuneError,
|
||||||
|
0x75: RuneError,
|
||||||
|
0x76: RuneError,
|
||||||
|
0x77: RuneError,
|
||||||
|
0x78: RuneError,
|
||||||
|
0x79: '`',
|
||||||
|
0x7a: ':',
|
||||||
|
0x7b: '#',
|
||||||
|
0x7c: '@',
|
||||||
|
0x7d: '\'',
|
||||||
|
0x7e: '=',
|
||||||
|
0x7f: '"',
|
||||||
|
0x80: RuneError,
|
||||||
|
0x81: 'a',
|
||||||
|
0x82: 'b',
|
||||||
|
0x83: 'c',
|
||||||
|
0x84: 'd',
|
||||||
|
0x85: 'e',
|
||||||
|
0x86: 'f',
|
||||||
|
0x87: 'g',
|
||||||
|
0x88: 'h',
|
||||||
|
0x89: 'i',
|
||||||
|
0x8a: RuneError,
|
||||||
|
0x8b: RuneError,
|
||||||
|
0x8c: RuneError,
|
||||||
|
0x8d: RuneError,
|
||||||
|
0x8e: RuneError,
|
||||||
|
0x8f: '±',
|
||||||
|
0x90: RuneError,
|
||||||
|
0x91: 'j',
|
||||||
|
0x92: 'k',
|
||||||
|
0x93: 'l',
|
||||||
|
0x94: 'm',
|
||||||
|
0x95: 'n',
|
||||||
|
0x96: 'o',
|
||||||
|
0x97: 'p',
|
||||||
|
0x98: 'q',
|
||||||
|
0x99: 'r',
|
||||||
|
0x9a: RuneError,
|
||||||
|
0x9b: RuneError,
|
||||||
|
0x9c: RuneError,
|
||||||
|
0x9d: RuneError,
|
||||||
|
0x9e: RuneError,
|
||||||
|
0x9f: RuneError,
|
||||||
|
0xa0: RuneError,
|
||||||
|
0xa1: '~',
|
||||||
|
0xa2: 's',
|
||||||
|
0xa3: 't',
|
||||||
|
0xa4: 'u',
|
||||||
|
0xa5: 'v',
|
||||||
|
0xa6: 'w',
|
||||||
|
0xa7: 'x',
|
||||||
|
0xa8: 'y',
|
||||||
|
0xa9: 'z',
|
||||||
|
0xaa: RuneError,
|
||||||
|
0xab: RuneError,
|
||||||
|
0xac: RuneError,
|
||||||
|
0xad: RuneError,
|
||||||
|
0xae: RuneError,
|
||||||
|
0xaf: RuneError,
|
||||||
|
0xb0: '^',
|
||||||
|
0xb1: RuneError,
|
||||||
|
0xb2: RuneError,
|
||||||
|
0xb3: RuneError,
|
||||||
|
0xb4: RuneError,
|
||||||
|
0xb5: RuneError,
|
||||||
|
0xb6: RuneError,
|
||||||
|
0xb7: RuneError,
|
||||||
|
0xb8: RuneError,
|
||||||
|
0xb9: RuneError,
|
||||||
|
0xba: '[',
|
||||||
|
0xbb: ']',
|
||||||
|
0xbc: RuneError,
|
||||||
|
0xbd: RuneError,
|
||||||
|
0xbe: RuneError,
|
||||||
|
0xbf: RuneError,
|
||||||
|
0xc0: '{',
|
||||||
|
0xc1: 'A',
|
||||||
|
0xc2: 'B',
|
||||||
|
0xc3: 'C',
|
||||||
|
0xc4: 'D',
|
||||||
|
0xc5: 'E',
|
||||||
|
0xc6: 'F',
|
||||||
|
0xc7: 'G',
|
||||||
|
0xc8: 'H',
|
||||||
|
0xc9: 'I',
|
||||||
|
0xca: '\xad', // NB: soft hyphen
|
||||||
|
0xcb: RuneError,
|
||||||
|
0xcc: RuneError,
|
||||||
|
0xcd: RuneError,
|
||||||
|
0xce: RuneError,
|
||||||
|
0xcf: RuneError,
|
||||||
|
0xd0: '}',
|
||||||
|
0xd1: 'J',
|
||||||
|
0xd2: 'K',
|
||||||
|
0xd3: 'L',
|
||||||
|
0xd4: 'M',
|
||||||
|
0xd5: 'N',
|
||||||
|
0xd6: 'O',
|
||||||
|
0xd7: 'P',
|
||||||
|
0xd8: 'Q',
|
||||||
|
0xd9: 'R',
|
||||||
|
0xda: RuneError,
|
||||||
|
0xdb: RuneError,
|
||||||
|
0xdc: RuneError,
|
||||||
|
0xdd: RuneError,
|
||||||
|
0xde: RuneError,
|
||||||
|
0xdf: RuneError,
|
||||||
|
0xe0: '\\',
|
||||||
|
0xe1: '\u2007', // Non-breaking space
|
||||||
|
0xe2: 'S',
|
||||||
|
0xe3: 'T',
|
||||||
|
0xe4: 'U',
|
||||||
|
0xe5: 'V',
|
||||||
|
0xe6: 'W',
|
||||||
|
0xe7: 'X',
|
||||||
|
0xe8: 'Y',
|
||||||
|
0xe9: 'Z',
|
||||||
|
0xea: RuneError,
|
||||||
|
0xeb: RuneError,
|
||||||
|
0xec: RuneError,
|
||||||
|
0xed: RuneError,
|
||||||
|
0xee: RuneError,
|
||||||
|
0xef: RuneError,
|
||||||
|
0xf0: '0',
|
||||||
|
0xf1: '1',
|
||||||
|
0xf2: '2',
|
||||||
|
0xf3: '3',
|
||||||
|
0xf4: '4',
|
||||||
|
0xf5: '5',
|
||||||
|
0xf6: '6',
|
||||||
|
0xf7: '7',
|
||||||
|
0xf8: '8',
|
||||||
|
0xf9: '9',
|
||||||
|
0xfa: RuneError,
|
||||||
|
0xfb: RuneError,
|
||||||
|
0xfc: RuneError,
|
||||||
|
0xfd: RuneError,
|
||||||
|
0xfe: RuneError,
|
||||||
|
0xff: RuneError,
|
||||||
|
}}
|
||||||
|
cm.Init()
|
||||||
|
EBCDIC = cm
|
||||||
|
}
|
33
vendor/github.com/gdamore/encoding/latin1.go
generated
vendored
Normal file
33
vendor/github.com/gdamore/encoding/latin1.go
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright 2015 Garrett D'Amore
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the license at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package encoding
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golang.org/x/text/encoding"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ISO8859_1 represents the 8-bit ISO8859-1 scheme. It decodes directly to
|
||||||
|
// UTF-8 without change, as all ISO8859-1 values are legal UTF-8.
|
||||||
|
// Unicode values less than 256 (i.e. 8 bits) map 1:1 with 8859-1.
|
||||||
|
// It encodes runes outside of that to 0x1A, the ASCII substitution character.
|
||||||
|
var ISO8859_1 encoding.Encoding
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cm := &Charmap{}
|
||||||
|
cm.Init()
|
||||||
|
|
||||||
|
// 8859-1 is the 8-bit identity map for Unicode.
|
||||||
|
ISO8859_1 = cm
|
||||||
|
}
|
35
vendor/github.com/gdamore/encoding/latin5.go
generated
vendored
Normal file
35
vendor/github.com/gdamore/encoding/latin5.go
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright 2015 Garrett D'Amore
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the license at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package encoding
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golang.org/x/text/encoding"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ISO8859_9 represents the 8-bit ISO8859-9 scheme.
|
||||||
|
var ISO8859_9 encoding.Encoding
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cm := &Charmap{Map: map[byte]rune{
|
||||||
|
0xD0: 'Ğ',
|
||||||
|
0xDD: 'İ',
|
||||||
|
0xDE: 'Ş',
|
||||||
|
0xF0: 'ğ',
|
||||||
|
0xFD: 'ı',
|
||||||
|
0xFE: 'ş',
|
||||||
|
}}
|
||||||
|
cm.Init()
|
||||||
|
ISO8859_9 = cm
|
||||||
|
}
|
35
vendor/github.com/gdamore/encoding/utf8.go
generated
vendored
Normal file
35
vendor/github.com/gdamore/encoding/utf8.go
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright 2015 Garrett D'Amore
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the license at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package encoding
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golang.org/x/text/encoding"
|
||||||
|
)
|
||||||
|
|
||||||
|
type validUtf8 struct{}
|
||||||
|
|
||||||
|
// UTF8 is an encoding for UTF-8. All it does is verify that the UTF-8
|
||||||
|
// in is valid. The main reason for its existence is that it will detect
|
||||||
|
// and report ErrSrcShort or ErrDstShort, whereas the Nop encoding just
|
||||||
|
// passes every byte, blithely.
|
||||||
|
var UTF8 encoding.Encoding = validUtf8{}
|
||||||
|
|
||||||
|
func (validUtf8) NewDecoder() *encoding.Decoder {
|
||||||
|
return &encoding.Decoder{Transformer: encoding.UTF8Validator}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (validUtf8) NewEncoder() *encoding.Encoder {
|
||||||
|
return &encoding.Encoder{Transformer: encoding.UTF8Validator}
|
||||||
|
}
|
13
vendor/github.com/gdamore/tcell/.appveyor.yml
generated
vendored
Normal file
13
vendor/github.com/gdamore/tcell/.appveyor.yml
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
version: 1.0.{build}
|
||||||
|
clone_folder: c:\gopath\src\github.com\gdamore\tcell
|
||||||
|
environment:
|
||||||
|
GOPATH: c:\gopath
|
||||||
|
build_script:
|
||||||
|
- go version
|
||||||
|
- go env
|
||||||
|
- SET PATH=%LOCALAPPDATA%\atom\bin;%GOPATH%\bin;%PATH%
|
||||||
|
- go get -t ./...
|
||||||
|
- go build
|
||||||
|
- go install ./...
|
||||||
|
test_script:
|
||||||
|
- go test ./...
|
1
vendor/github.com/gdamore/tcell/.gitignore
generated
vendored
Normal file
1
vendor/github.com/gdamore/tcell/.gitignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
coverage.txt
|
17
vendor/github.com/gdamore/tcell/.travis.yml
generated
vendored
Normal file
17
vendor/github.com/gdamore/tcell/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
language: go
|
||||||
|
|
||||||
|
go:
|
||||||
|
- 1.5.x
|
||||||
|
- 1.6.x
|
||||||
|
- 1.7.x
|
||||||
|
- 1.8.x
|
||||||
|
- master
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- go get -t -v ./...
|
||||||
|
|
||||||
|
script:
|
||||||
|
- go test -race -coverprofile=coverage.txt -covermode=atomic
|
||||||
|
|
||||||
|
after_success:
|
||||||
|
- bash <(curl -s https://codecov.io/bash)
|
4
vendor/github.com/gdamore/tcell/AUTHORS
generated
vendored
Normal file
4
vendor/github.com/gdamore/tcell/AUTHORS
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
Garrett D'Amore <garrett@damore.org>
|
||||||
|
Zachary Yedidia <zyedidia@gmail.com>
|
||||||
|
Junegunn Choi <junegunn.c@gmail.com>
|
||||||
|
Staysail Systems, Inc. <info@staysail.tech>
|
202
vendor/github.com/gdamore/tcell/LICENSE
generated
vendored
Normal file
202
vendor/github.com/gdamore/tcell/LICENSE
generated
vendored
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
262
vendor/github.com/gdamore/tcell/README.md
generated
vendored
Normal file
262
vendor/github.com/gdamore/tcell/README.md
generated
vendored
Normal file
@ -0,0 +1,262 @@
|
|||||||
|
## tcell
|
||||||
|
|
||||||
|
[](https://travis-ci.org/gdamore/tcell)
|
||||||
|
[](https://ci.appveyor.com/project/gdamore/tcell)
|
||||||
|
[](https://github.com/gdamore/tcell/blob/master/LICENSE)
|
||||||
|
[](https://gitter.im/gdamore/tcell)
|
||||||
|
[](https://godoc.org/github.com/gdamore/tcell)
|
||||||
|
[](http://goreportcard.com/report/gdamore/tcell)
|
||||||
|
[](https://codecov.io/gh/gdamore/tcell)
|
||||||
|
|
||||||
|
|
||||||
|
> _Tcell is a work in progress (Gamma).
|
||||||
|
> Please use with caution; interfaces may change in before final release.
|
||||||
|
> That said, our confidence in Tcell's stability is increasing. If you
|
||||||
|
> would like to use it in your own application, it is recommended that
|
||||||
|
> you drop a message to garrett@damore.org before commitment._
|
||||||
|
|
||||||
|
Package tcell provides a cell based view for text terminals, like xterm.
|
||||||
|
It was inspired by termbox, but differs from termbox in some important
|
||||||
|
ways. It also adds substantial functionality beyond termbox.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
* [proxima5](https://github.com/gdamore/proxima5) - space shooter ([video](https://youtu.be/jNxKTCmY_bQ))
|
||||||
|
* [govisor](https://github.com/gdamore/govisor) - service management UI ([screenshot](http://2.bp.blogspot.com/--OsvnfzSNow/Vf7aqMw3zXI/AAAAAAAAARo/uOMtOvw4Sbg/s1600/Screen%2BShot%2B2015-09-20%2Bat%2B9.08.41%2BAM.png))
|
||||||
|
* mouse demo - [screenshot](http://2.bp.blogspot.com/-fWvW5opT0es/VhIdItdKqJI/AAAAAAAAATE/7Ojc0L1SpB0/s1600/Screen%2BShot%2B2015-10-04%2Bat%2B11.47.13%2BPM.png) - included mouse test
|
||||||
|
* [gomatrix](https://github.com/gdamore/gomatrix) - converted from Termbox
|
||||||
|
* [micro](https://github.com/zyedidia/micro/) - lightweight text editor with syntax-highlighting and themes
|
||||||
|
* [godu](https://github.com/viktomas/godu) - simple golang utility helping to discover large files/folders.
|
||||||
|
|
||||||
|
## Pure Go Terminfo Database
|
||||||
|
|
||||||
|
First, it includes a full parser and expander for terminfo capability strings,
|
||||||
|
so that it can avoid hard coding escape strings for formatting. It also favors
|
||||||
|
portability, and includes support for all POSIX systems, at the slight expense
|
||||||
|
of needing cgo support for terminal initializations. (This may be corrected
|
||||||
|
when Go provides standard support for terminal handling via termio ioctls on
|
||||||
|
all POSIX platforms.) The database itself, while built using CGO, as well
|
||||||
|
as the parser for it, is implemented in Pure Go.
|
||||||
|
|
||||||
|
The database is also flexible & extensible, and can modified by either running a
|
||||||
|
program to build the database, or hand editing of simple JSON files.
|
||||||
|
|
||||||
|
## More Portable
|
||||||
|
|
||||||
|
Tcell is portable to a wider variety of systems. It relies on standard
|
||||||
|
POSIX supported function calls (on POSIX platforms) for setting terminal
|
||||||
|
modes, which leads to improved support for a broader array of platforms.
|
||||||
|
This does come at the cost of requiring your code to be able to use CGO, but
|
||||||
|
we believe that the vastly improved portability justifies this
|
||||||
|
requirement. Note that the functions called are part of the standard C
|
||||||
|
library, so there shouldn't be any additional external requirements beyond
|
||||||
|
that required for every POSIX program.
|
||||||
|
|
||||||
|
## No async IO
|
||||||
|
|
||||||
|
Tcell is able to operate without requiring SIGIO signals (unlike Termbox),
|
||||||
|
or asynchronous I/O, and can instead use standard Go file
|
||||||
|
objects and Go routines. This means it should be safe, especially for
|
||||||
|
use with programs that use exec, or otherwise need to manipulate the
|
||||||
|
tty streams. This model is also much closer to idiomatic Go, leading
|
||||||
|
to fewer surprises.
|
||||||
|
|
||||||
|
## Richer Unicode & non-Unicode support
|
||||||
|
|
||||||
|
Tcell includes enhanced support for Unicode, include wide characters and
|
||||||
|
combining characters, provided your terminal can support them. Note that
|
||||||
|
Windows terminals generally don't support the full Unicode repertoire.
|
||||||
|
|
||||||
|
It will also convert to and from Unicode locales, so that the program
|
||||||
|
can work with UTF-8 internally, and get reasonable output in other locales.
|
||||||
|
We try hard to convert to native characters on both input and output, and
|
||||||
|
on output Tcell even makes use of the alternate character set to facilitate
|
||||||
|
drawing certain characters.
|
||||||
|
|
||||||
|
## More Function Keys
|
||||||
|
|
||||||
|
It also has richer support for a larger number of
|
||||||
|
special keys that some terminals can send.
|
||||||
|
|
||||||
|
## Better color handling
|
||||||
|
|
||||||
|
Tcell will respect your terminal's color space as specified within your terminfo
|
||||||
|
entries, so that for example attempts to emit color sequences on VT100 terminals
|
||||||
|
won't result in unintended consequences.
|
||||||
|
|
||||||
|
In Windows mode, Tcell supports 16 colors, bold, dim, and reverse,
|
||||||
|
instead of just termbox's 8 colors with reverse. (Note that there is some
|
||||||
|
conflation with bold/dim and colors.)
|
||||||
|
|
||||||
|
Tcell maps 16 colors down to 8, for Terminals that need it. (The upper
|
||||||
|
8 colors are just brighter versions of the lower 8.)
|
||||||
|
|
||||||
|
## Better mouse support
|
||||||
|
|
||||||
|
Tcell supports enhanced mouse tracking mode, so your application can receive
|
||||||
|
regular mouse motion events, and wheel events, if your terminal supports it.
|
||||||
|
|
||||||
|
## Why not just patch termbox-go?
|
||||||
|
|
||||||
|
I started this project originally by submitting patches to the author of
|
||||||
|
go-termbox, but due to some fundamental differences of opinion, I thought
|
||||||
|
it might be simpler just to start from scratch. At this point, Tcell has
|
||||||
|
far exceeded the capabilities of termbox.
|
||||||
|
|
||||||
|
## Termbox compatibility
|
||||||
|
|
||||||
|
A compatibility layer for termbox is provided in the compat
|
||||||
|
directory. To use it, try importing "github.com/gdamore/tcell/termbox"
|
||||||
|
instead. Most termbox-go programs will probably work without further
|
||||||
|
modification.
|
||||||
|
|
||||||
|
## Working With Unicode
|
||||||
|
|
||||||
|
Internally Tcell uses UTF-8, just like Go. However, Tcell understands how to
|
||||||
|
convert to and from other character sets, using the capabilities of
|
||||||
|
the golang.org/x/text/encoding packages. Your application must supply
|
||||||
|
them, as the full set of the most common ones bloats the program by about
|
||||||
|
2MB. If you're lazy, and want them all anyway, see the encoding
|
||||||
|
sub-directory.
|
||||||
|
|
||||||
|
## Wide & Combining Characters
|
||||||
|
|
||||||
|
The SetContent() API takes a primary rune, and an optional list of combining
|
||||||
|
runes. If any of the runes is a wide (East Asian) rune occupying two cells,
|
||||||
|
then the library will skip output from the following cell, but care must be
|
||||||
|
taken in the application to avoid explicitly attempting to set content in the
|
||||||
|
next cell, otherwise the results are undefined. (Normally wide character
|
||||||
|
is displayed, and the other character is not; do not depend on that behavior.)
|
||||||
|
|
||||||
|
Experience has shown that the vanilla Windows 8 console application does not
|
||||||
|
support any of these characters properly, but at least some options like
|
||||||
|
ConEmu do support Wide characters at least.
|
||||||
|
|
||||||
|
## Colors
|
||||||
|
|
||||||
|
Tcell assumes the ANSI/XTerm color model, including the 256 color map that
|
||||||
|
XTerm uses when it supports 256 colors. The terminfo guidance will be
|
||||||
|
honored, with respect to the number of colors supported. Also, only
|
||||||
|
terminals which expose ANSI style setaf and setab will support color;
|
||||||
|
if you have a color terminal that only has setf and setb, please let me
|
||||||
|
know; it wouldn't be hard to add that if there is need.
|
||||||
|
|
||||||
|
## 24-bit Color
|
||||||
|
|
||||||
|
Tcell _supports true color_! (That is, if your terminal can support it,
|
||||||
|
Tcell can accurately display 24-bit color.)
|
||||||
|
|
||||||
|
To use 24-bit color, you need to use a terminal that supports it. Modern
|
||||||
|
xterm and similar teminal emulators can support this. As terminfo lacks any
|
||||||
|
way to describe this capability, we fabricate the capability for
|
||||||
|
terminals with names ending in *-truecolor. The stock distribution ships
|
||||||
|
with a database that defines xterm-truecolor. To try it out, set your
|
||||||
|
TERM variable to xterm-truecolor.
|
||||||
|
|
||||||
|
When using TrueColor, programs will display the colors that the programmer
|
||||||
|
intended, overriding any "themes" you may have set in your terminal
|
||||||
|
emulator. (For some cases, accurate color fidelity is more important
|
||||||
|
than respecting themes. For other cases, such as typical text apps that
|
||||||
|
only use a few colors, its more desirable to respect the themes that
|
||||||
|
the user has established.)
|
||||||
|
|
||||||
|
If you find this undesirable, you can either use a TERM variable
|
||||||
|
that lacks the TRUECOLOR setting, or set TCELL_TRUECOLOR=disable in your
|
||||||
|
environment.
|
||||||
|
|
||||||
|
## Performance
|
||||||
|
|
||||||
|
Reasonable attempts have been made to minimize sending data to terminals,
|
||||||
|
avoiding repeated sequences or drawing the same cell on refresh updates.
|
||||||
|
|
||||||
|
## Terminfo
|
||||||
|
|
||||||
|
(Not relevent for Windows users.)
|
||||||
|
|
||||||
|
The Terminfo implementation operates with two forms of database. The first
|
||||||
|
is the database.go file, which contains a number of real database entries
|
||||||
|
that are compiled into the program directly. This should minimize calling
|
||||||
|
out to database file searches.
|
||||||
|
|
||||||
|
The second is a JSON file, that contains the same information, which can
|
||||||
|
be located either by the $TCELLDB environment file, $HOME/.tcelldb, or is
|
||||||
|
located in the Go source directory as database.json.
|
||||||
|
|
||||||
|
These files (both the Go database.go and the database.json) file can be
|
||||||
|
generated using the mkinfo.go program. If you need to regnerate the
|
||||||
|
entire set for some reason, run the mkdatabase.sh file. The generation
|
||||||
|
uses the terminfo routines on the system to populate the data files.
|
||||||
|
|
||||||
|
The mkinfo.go program can also be used to generate specific database entries
|
||||||
|
for named terminals, in case your favorite terminal is missing. (If you
|
||||||
|
find that this is the case, please let me know and I'll try to add it!)
|
||||||
|
|
||||||
|
Tcell requires that the terminal support the 'cup' mode of cursor addressing.
|
||||||
|
Terminals without absolute cursor addressability are not supported.
|
||||||
|
This is unlikely to be a problem; such terminals have not been mass produced
|
||||||
|
since the early 1970s.
|
||||||
|
|
||||||
|
## Mouse Support
|
||||||
|
|
||||||
|
Mouse support is detected via the "kmous" terminfo variable, however,
|
||||||
|
enablement/disablement and decoding mouse events is done using hard coded
|
||||||
|
sequences based on the XTerm X11 model. As of this writing all popular
|
||||||
|
terminals with mouse tracking support this model. (Full terminfo support
|
||||||
|
is not possible as terminfo sequences are not defined.)
|
||||||
|
|
||||||
|
On Windows, the mouse works normally.
|
||||||
|
|
||||||
|
Mouse wheel buttons on various terminals are known to work, but the support
|
||||||
|
in terminal emulators, as well as support for various buttons and
|
||||||
|
live mouse tracking, varies widely. As a particular datum, MacOS X Terminal
|
||||||
|
does not support Mouse events at all (as of MacOS 10.10, aka Yosemite.) The
|
||||||
|
excellent iTerm application is fully supported, as is vanilla XTerm.
|
||||||
|
|
||||||
|
Mouse tracking with live tracking also varies widely. Current XTerm
|
||||||
|
implementations, as well as current Screen and iTerm2, and Windows
|
||||||
|
consoles, all support this quite nicely. On other platforms you might
|
||||||
|
find that only mouse click and release events are reported, with
|
||||||
|
no intervening motion events. It really depends on your terminal.
|
||||||
|
|
||||||
|
## Testablity
|
||||||
|
|
||||||
|
There is a SimulationScreen, that can be used to simulate a real screen
|
||||||
|
for automated testing. The supplied tests do this. The simulation contains
|
||||||
|
event delivery, screen resizing support, and capabilities to inject events
|
||||||
|
and examine "physical" screen contents.
|
||||||
|
|
||||||
|
## Platforms
|
||||||
|
|
||||||
|
### Systems (Linux, FreeBSD, MacOS, Solaris, etc.)
|
||||||
|
|
||||||
|
On POSIX systems, a POSIX termios implementation with /dev/tty is required.
|
||||||
|
On a small subset of these platforms (such as Solaris/illumos), we require
|
||||||
|
cgo to run, in order to access termios. (Note that Linux and BSD systems
|
||||||
|
do not require CGO for most purposes.)
|
||||||
|
|
||||||
|
(Note: CGO support is required if you wish to rebuild the terminal database
|
||||||
|
from the system's native terminfo binary files. This is because we use the
|
||||||
|
system's native libterminfo to access that binary data. We probably could
|
||||||
|
eliminate that in the future by using a terminfo decompiler such as infocmp.)
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
|
||||||
|
Windows console mode applications are supported. Unfortunately mintty
|
||||||
|
and other cygwin style applications are not supported.
|
||||||
|
|
||||||
|
Modern console applications like ConEmu support all the good features
|
||||||
|
(resize, mouse tracking, etc.)
|
||||||
|
|
||||||
|
I haven't figured out how to cleanly resolve the dichotomy between cygwin
|
||||||
|
style termios and the Windows Console API; it seems that perhaps nobody else
|
||||||
|
has either. If anyone has suggestions, let me know! Really, if you're
|
||||||
|
using a Windows application, you should use the native Windows console or a
|
||||||
|
fully compatible console implementation. Hopefully the Windows 10 console
|
||||||
|
is more functional in this regard.
|
||||||
|
|
||||||
|
### Plan9 and Native Client (Nacl)
|
||||||
|
|
||||||
|
The nacl and plan9 platforms won't work, but compilation stubs are supplied
|
||||||
|
for folks that want to include parts of this in software targetting those
|
||||||
|
platforms. The Simulation screen works, but as Tcell doesn't know how to
|
||||||
|
allocate a real screen object on those platforms, NewScreen() will fail.
|
32
vendor/github.com/gdamore/tcell/attr.go
generated
vendored
Normal file
32
vendor/github.com/gdamore/tcell/attr.go
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright 2015 The TCell Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the license at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package tcell
|
||||||
|
|
||||||
|
// AttrMask represents a mask of text attributes, apart from color.
|
||||||
|
// Note that support for attributes may vary widely across terminals.
|
||||||
|
type AttrMask int
|
||||||
|
|
||||||
|
// Attributes are not colors, but affect the display of text. They can
|
||||||
|
// be combined.
|
||||||
|
const (
|
||||||
|
AttrBold AttrMask = 1 << (25 + iota)
|
||||||
|
AttrBlink
|
||||||
|
AttrReverse
|
||||||
|
AttrUnderline
|
||||||
|
AttrDim
|
||||||
|
AttrNone AttrMask = 0 // Just normal text.
|
||||||
|
)
|
||||||
|
|
||||||
|
const attrAll = AttrBold | AttrBlink | AttrReverse | AttrUnderline | AttrDim
|
186
vendor/github.com/gdamore/tcell/cell.go
generated
vendored
Normal file
186
vendor/github.com/gdamore/tcell/cell.go
generated
vendored
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
// Copyright 2015 The TCell Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the license at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package tcell
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/mattn/go-runewidth"
|
||||||
|
)
|
||||||
|
|
||||||
|
type cell struct {
|
||||||
|
currMain rune
|
||||||
|
currComb []rune
|
||||||
|
currStyle Style
|
||||||
|
lastMain rune
|
||||||
|
lastStyle Style
|
||||||
|
lastComb []rune
|
||||||
|
width int
|
||||||
|
}
|
||||||
|
|
||||||
|
// CellBuffer represents a two dimensional array of character cells.
|
||||||
|
// This is primarily intended for use by Screen implementors; it
|
||||||
|
// contains much of the common code they need. To create one, just
|
||||||
|
// declare a variable of its type; no explicit initialization is necessary.
|
||||||
|
//
|
||||||
|
// CellBuffer is not thread safe.
|
||||||
|
type CellBuffer struct {
|
||||||
|
w int
|
||||||
|
h int
|
||||||
|
cells []cell
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetContent sets the contents (primary rune, combining runes,
|
||||||
|
// and style) for a cell at a given location.
|
||||||
|
func (cb *CellBuffer) SetContent(x int, y int,
|
||||||
|
mainc rune, combc []rune, style Style) {
|
||||||
|
|
||||||
|
if x >= 0 && y >= 0 && x < cb.w && y < cb.h {
|
||||||
|
c := &cb.cells[(y*cb.w)+x]
|
||||||
|
|
||||||
|
i := 0
|
||||||
|
for i < len(combc) {
|
||||||
|
r := combc[i]
|
||||||
|
if runewidth.RuneWidth(r) != 0 {
|
||||||
|
// not a combining character, yank it
|
||||||
|
combc = append(combc[:i-1], combc[i+1:]...)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.currMain != mainc {
|
||||||
|
c.width = runewidth.RuneWidth(mainc)
|
||||||
|
}
|
||||||
|
c.currMain = mainc
|
||||||
|
c.currComb = combc
|
||||||
|
c.currStyle = style
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetContent returns the contents of a character cell, including the
|
||||||
|
// primary rune, any combining character runes (which will usually be
|
||||||
|
// nil), the style, and the display width in cells. (The width can be
|
||||||
|
// either 1, normally, or 2 for East Asian full-width characters.)
|
||||||
|
func (cb *CellBuffer) GetContent(x, y int) (rune, []rune, Style, int) {
|
||||||
|
var mainc rune
|
||||||
|
var combc []rune
|
||||||
|
var style Style
|
||||||
|
var width int
|
||||||
|
if x >= 0 && y >= 0 && x < cb.w && y < cb.h {
|
||||||
|
c := &cb.cells[(y*cb.w)+x]
|
||||||
|
mainc, combc, style = c.currMain, c.currComb, c.currStyle
|
||||||
|
if width = c.width; width == 0 || mainc < ' ' {
|
||||||
|
width = 1
|
||||||
|
mainc = ' '
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mainc, combc, style, width
|
||||||
|
}
|
||||||
|
|
||||||
|
// Size returns the (width, height) in cells of the buffer.
|
||||||
|
func (cb *CellBuffer) Size() (int, int) {
|
||||||
|
return cb.w, cb.h
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invalidate marks all characters within the buffer as dirty.
|
||||||
|
func (cb *CellBuffer) Invalidate() {
|
||||||
|
for i := range cb.cells {
|
||||||
|
cb.cells[i].lastMain = rune(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dirty checks if a character at the given location needs an
|
||||||
|
// to be refreshed on the physical display. This returns true
|
||||||
|
// if the cell content is different since the last time it was
|
||||||
|
// marked clean.
|
||||||
|
func (cb *CellBuffer) Dirty(x, y int) bool {
|
||||||
|
if x >= 0 && y >= 0 && x < cb.w && y < cb.h {
|
||||||
|
c := &cb.cells[(y*cb.w)+x]
|
||||||
|
if c.lastMain == rune(0) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if c.lastMain != c.currMain {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if c.lastStyle != c.currStyle {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if len(c.lastComb) != len(c.currComb) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
for i := range c.lastComb {
|
||||||
|
if c.lastComb[i] != c.currComb[i] {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetDirty is normally used to indicate that a cell has
|
||||||
|
// been displayed (in which case dirty is false), or to manually
|
||||||
|
// force a cell to be marked dirty.
|
||||||
|
func (cb *CellBuffer) SetDirty(x, y int, dirty bool) {
|
||||||
|
if x >= 0 && y >= 0 && x < cb.w && y < cb.h {
|
||||||
|
c := &cb.cells[(y*cb.w)+x]
|
||||||
|
if dirty {
|
||||||
|
c.lastMain = rune(0)
|
||||||
|
} else {
|
||||||
|
if c.currMain == rune(0) {
|
||||||
|
c.currMain = ' '
|
||||||
|
}
|
||||||
|
c.lastMain = c.currMain
|
||||||
|
c.lastComb = c.currComb
|
||||||
|
c.lastStyle = c.currStyle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resize is used to resize the cells array, with different dimensions,
|
||||||
|
// while preserving the original contents. The cells will be invalidated
|
||||||
|
// so that they can be redrawn.
|
||||||
|
func (cb *CellBuffer) Resize(w, h int) {
|
||||||
|
|
||||||
|
if cb.h == h && cb.w == w {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
newc := make([]cell, w*h)
|
||||||
|
for y := 0; y < h && y < cb.h; y++ {
|
||||||
|
for x := 0; x < w && x < cb.w; x++ {
|
||||||
|
oc := &cb.cells[(y*cb.w)+x]
|
||||||
|
nc := &newc[(y*w)+x]
|
||||||
|
nc.currMain = oc.currMain
|
||||||
|
nc.currComb = oc.currComb
|
||||||
|
nc.currStyle = oc.currStyle
|
||||||
|
nc.width = oc.width
|
||||||
|
nc.lastMain = rune(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cb.cells = newc
|
||||||
|
cb.h = h
|
||||||
|
cb.w = w
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fill fills the entire cell buffer array with the specified character
|
||||||
|
// and style. Normally choose ' ' to clear the screen. This API doesn't
|
||||||
|
// support combining characters.
|
||||||
|
func (cb *CellBuffer) Fill(r rune, style Style) {
|
||||||
|
for i := range cb.cells {
|
||||||
|
c := &cb.cells[i]
|
||||||
|
c.currMain = r
|
||||||
|
c.currComb = nil
|
||||||
|
c.currStyle = style
|
||||||
|
}
|
||||||
|
}
|
21
vendor/github.com/gdamore/tcell/charset_stub.go
generated
vendored
Normal file
21
vendor/github.com/gdamore/tcell/charset_stub.go
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// +build plan9 nacl
|
||||||
|
|
||||||
|
// Copyright 2015 The TCell Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the license at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package tcell
|
||||||
|
|
||||||
|
func getCharset() string {
|
||||||
|
return ""
|
||||||
|
}
|
49
vendor/github.com/gdamore/tcell/charset_unix.go
generated
vendored
Normal file
49
vendor/github.com/gdamore/tcell/charset_unix.go
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
// +build !windows,!nacl,!plan9
|
||||||
|
|
||||||
|
// Copyright 2016 The TCell Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the license at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package tcell
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func getCharset() string {
|
||||||
|
// Determine the character set. This can help us later.
|
||||||
|
// Per POSIX, we search for LC_ALL first, then LC_CTYPE, and
|
||||||
|
// finally LANG. First one set wins.
|
||||||
|
locale := ""
|
||||||
|
if locale = os.Getenv("LC_ALL"); locale == "" {
|
||||||
|
if locale = os.Getenv("LC_CTYPE"); locale == "" {
|
||||||
|
locale = os.Getenv("LANG")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if locale == "POSIX" || locale == "C" {
|
||||||
|
return "US-ASCII"
|
||||||
|
}
|
||||||
|
if i := strings.IndexRune(locale, '@'); i >= 0 {
|
||||||
|
locale = locale[:i]
|
||||||
|
}
|
||||||
|
if i := strings.IndexRune(locale, '.'); i >= 0 {
|
||||||
|
locale = locale[i+1:]
|
||||||
|
} else {
|
||||||
|
// Default assumption, and on Linux we can see LC_ALL
|
||||||
|
// without a character set, which we assume implies UTF-8.
|
||||||
|
return "UTF-8"
|
||||||
|
}
|
||||||
|
// XXX: add support for aliases
|
||||||
|
return locale
|
||||||
|
}
|
21
vendor/github.com/gdamore/tcell/charset_windows.go
generated
vendored
Normal file
21
vendor/github.com/gdamore/tcell/charset_windows.go
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// +build windows
|
||||||
|
|
||||||
|
// Copyright 2015 The TCell Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the license at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package tcell
|
||||||
|
|
||||||
|
func getCharset() string {
|
||||||
|
return "UTF-16"
|
||||||
|
}
|
1019
vendor/github.com/gdamore/tcell/color.go
generated
vendored
Normal file
1019
vendor/github.com/gdamore/tcell/color.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
52
vendor/github.com/gdamore/tcell/colorfit.go
generated
vendored
Normal file
52
vendor/github.com/gdamore/tcell/colorfit.go
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
// Copyright 2016 The TCell Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the license at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package tcell
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/lucasb-eyer/go-colorful"
|
||||||
|
"math"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FindColor attempts to find a given color, or the best match possible for it,
|
||||||
|
// from the palette given. This is an expensive operation, so results should
|
||||||
|
// be cached by the caller.
|
||||||
|
func FindColor(c Color, palette []Color) Color {
|
||||||
|
match := ColorDefault
|
||||||
|
dist := float64(0)
|
||||||
|
r, g, b := c.RGB()
|
||||||
|
c1 := colorful.Color{
|
||||||
|
R: float64(r) / 255.0,
|
||||||
|
G: float64(g) / 255.0,
|
||||||
|
B: float64(b) / 255.0,
|
||||||
|
}
|
||||||
|
for _, d := range palette {
|
||||||
|
r, g, b = d.RGB()
|
||||||
|
c2 := colorful.Color{
|
||||||
|
R: float64(r) / 255.0,
|
||||||
|
G: float64(g) / 255.0,
|
||||||
|
B: float64(b) / 255.0,
|
||||||
|
}
|
||||||
|
// CIE94 is more accurate, but really really expensive.
|
||||||
|
nd := c1.DistanceCIE76(c2)
|
||||||
|
if math.IsNaN(nd) {
|
||||||
|
nd = math.Inf(1)
|
||||||
|
}
|
||||||
|
if match == ColorDefault || nd < dist {
|
||||||
|
match = d
|
||||||
|
dist = nd
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return match
|
||||||
|
}
|
23
vendor/github.com/gdamore/tcell/console_stub.go
generated
vendored
Normal file
23
vendor/github.com/gdamore/tcell/console_stub.go
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// +build !windows
|
||||||
|
|
||||||
|
// Copyright 2015 The TCell Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the license at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package tcell
|
||||||
|
|
||||||
|
// NewConsoleScreen returns a console based screen. This platform
|
||||||
|
// doesn't have support for any, so it returns nil and a suitable error.
|
||||||
|
func NewConsoleScreen() (Screen, error) {
|
||||||
|
return nil, ErrNoScreen
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user