ignore
1package version2
3import (4"encoding/json"5"errors"6"net/http"7)
8
9var Version string10
11func Latest() (version string, err error) {12if err != nil {13return "", err14}15
16resp, err := http.Get("https://api.github.com/repos/neptunsk1y/ignore/releases/latest")17if err != nil {18return19}20
21defer resp.Body.Close()22
23var release struct {24TagName string `json:"tag_name"`25}26
27err = json.NewDecoder(resp.Body).Decode(&release)28if err != nil {29return30}31
32if release.TagName == "" {33err = errors.New("empty tag name")34return35}36Version = release.TagName[1:]37return38}
39