Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/testmodBuilder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-05-17 11:50:18 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-05-17 11:50:18 +0300
commit8fa85d583cb0f1bfb00de8d0410b250fe0f8cd9e (patch)
tree0b307af28af0d1eb58d9e5858b9f1705ffe8e2e8
parentaa53ba81c9fb2f3b8e8804be6bc897554912a294 (diff)
Remove the GOOS global
-rw-r--r--testmodBuilder/build/go.mod2
-rw-r--r--testmodBuilder/mods/mods.go48
2 files changed, 36 insertions, 14 deletions
diff --git a/testmodBuilder/build/go.mod b/testmodBuilder/build/go.mod
index 8ec1415..47455b4 100644
--- a/testmodBuilder/build/go.mod
+++ b/testmodBuilder/build/go.mod
@@ -4,7 +4,7 @@ go 1.12
require (
github.com/gobuffalo/envy v1.7.0 // indirect
- github.com/gohugoio/hugo v0.55.6-0.20190515172700-cdd204ba7640 // indirect
+ github.com/gohugoio/hugo v0.55.6-0.20190515172700-cdd204ba7640
github.com/gohugoio/hugoTestHelpers/testmodBuilder/mods v0.0.0-20190515195342-8b1b2256735f
github.com/pkg/errors v0.8.1
github.com/shurcooL/go v0.0.0-20190330031554-6713ea532688
diff --git a/testmodBuilder/mods/mods.go b/testmodBuilder/mods/mods.go
index ec946e3..b14de1d 100644
--- a/testmodBuilder/mods/mods.go
+++ b/testmodBuilder/mods/mods.go
@@ -10,21 +10,21 @@ import (
const (
// Increment the minor version.
versionTemplate = "v1.%d.0"
-)
-// TODO(bep)
-func SetGOOS(s string) {
- goos = s
-}
+ basePath = "github.com/gohugoio/hugoTestModules1_"
+)
var goos string = runtime.GOOS
-func basePath() string {
- return "github.com/gohugoio/hugoTestModules1_" + goos
+type mdConfig struct {
+ goos string
}
type Md struct {
- name string
+ name string
+
+ *mdConfig
+
Vendor bool
Children Mds
@@ -72,7 +72,7 @@ func (m *Md) Name() string {
}
func (m *Md) Path() string {
- return path.Join(basePath(), m.Name())
+ return path.Join(basePath+m.goos, m.Name())
}
func (m *Md) init(idx int, parent *Md) {
@@ -89,8 +89,16 @@ func (m *Md) init(idx int, parent *Md) {
}
-func createModule() *Md {
- return &Md{
+func createModule(goos string) *Md {
+ if goos == "" {
+ goos = runtime.GOOS
+ }
+
+ cfg := &mdConfig{
+ goos: goos,
+ }
+
+ m := &Md{
Children: []*Md{
&Md{Children: []*Md{
&Md{},
@@ -102,6 +110,20 @@ func createModule() *Md {
}},
},
}
+
+ setMdConfig(cfg, m)
+
+ return m
+}
+
+func setMdConfig(cfg *mdConfig, mds ...*Md) {
+ if len(mds) == 0 {
+ return
+ }
+ for _, md := range mds {
+ md.mdConfig = cfg
+ setMdConfig(cfg, md.Children...)
+ }
}
func createSmallModule() *Md {
@@ -124,10 +146,10 @@ func (m Mds) Collect() Mds {
return res
}
-func CreateModules() Mds {
+func CreateModules(goos string) Mds {
mods := make(Mds, 2)
for i := 0; i < len(mods); i++ {
- mods[i] = createModule()
+ mods[i] = createModule(goos)
mods[i].init(i, nil)
}