aboutsummaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
authorGravatar Diego Bernardes <diego.bernardes@outlook.com> 2019-03-05 23:33:22 +0000
committerGravatar Abhinav Gupta <mail@abhinavg.net> 2019-03-05 15:33:22 -0800
commit76224eba02cfb97b18c724d69440b1fc999fccd6 (patch)
treec3d3140dcb40ebb197827df4a5132e32e918b9e1 /config.go
parente598b4a5dcbe7abf1815677cf0bf6a7983df7cc0 (diff)
downloadsally-76224eba02cfb97b18c724d69440b1fc999fccd6.tar.gz
sally-76224eba02cfb97b18c724d69440b1fc999fccd6.tar.zst
sally-76224eba02cfb97b18c724d69440b1fc999fccd6.zip
Support changing godoc instance (#38)
This adds the ability to change the godoc.org instance used by Sally to link to documentation by providing a new `godoc` section in the configuration.
Diffstat (limited to 'config.go')
-rw-r--r--config.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/config.go b/config.go
index 735b147..37045e9 100644
--- a/config.go
+++ b/config.go
@@ -4,14 +4,20 @@ import (
"fmt"
"io/ioutil"
"sort"
+ "strings"
- "gopkg.in/yaml.v2"
+ yaml "gopkg.in/yaml.v2"
)
+const _defaultGodocServer = "godoc.org"
+
// Config represents the structure of the yaml file
type Config struct {
URL string `yaml:"url"`
Packages map[string]Package `yaml:"packages"`
+ Godoc struct {
+ Host string `yaml:"host"`
+ } `yaml:"godoc"`
}
// Package details the options available for each repo
@@ -59,5 +65,15 @@ func Parse(path string) (*Config, error) {
return nil, fmt.Errorf("packages in %s must be alphabetically ordered", path)
}
+ if c.Godoc.Host == "" {
+ c.Godoc.Host = _defaultGodocServer
+ } else {
+ host := c.Godoc.Host
+ host = strings.TrimPrefix(host, "https://")
+ host = strings.TrimPrefix(host, "http://")
+ host = strings.TrimSuffix(host, "/")
+ c.Godoc.Host = host
+ }
+
return &c, err
}