Run of fresh-snapshots for golang-github-rakyll-globalconf

Merge these changes:

Summary

Merged new upstream version: 0.0~git20180912 (was: 0.0~git20140819).

Diff

Branch: main

diff --git a/.travis.yml b/.travis.yml
index fb9efcb..5b77ae6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,2 +1,2 @@
 language: go
-go: 1.2
+go: 1.5
diff --git a/README.md b/README.md
index dcbf4dd..363737c 100644
--- a/README.md
+++ b/README.md
@@ -86,7 +86,7 @@ Command line flags will override the environment variables.
 
 ~~~ go
 opts := globalconf.Options{
-	EnvPrefix: "MYAPP_",
+	EnvPrefix: "APPCONF_",
 	Filename:  "/path/to/config",
 }
 conf, err := globalconf.NewWithOptions(&opts)
diff --git a/debian/changelog b/debian/changelog
index 1e04d69..e35b8b7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-golang-github-rakyll-globalconf (0.0~git20140819-3) UNRELEASED; urgency=medium
+golang-github-rakyll-globalconf (0.0~git20180912-1) UNRELEASED; urgency=medium
 
   [ Alexandre Viau ]
   * Point Vcs-* urls to salsa.debian.org.
@@ -7,7 +7,11 @@ golang-github-rakyll-globalconf (0.0~git20140819-3) UNRELEASED; urgency=medium
   * Use secure copyright file specification URI.
   * Trim trailing whitespace.
 
- -- Alexandre Viau <aviau@debian.org>  Mon, 02 Apr 2018 20:13:55 -0400
+  [ Debian Janitor ]
+  * New upstream snapshot.
+  * Drop patch 0001-reparent-goini-library.patch, present upstream.
+
+ -- Alexandre Viau <aviau@debian.org>  Tue, 08 Mar 2022 10:09:51 -0000
 
 golang-github-rakyll-globalconf (0.0~git20140819-2) unstable; urgency=medium
 
diff --git a/debian/patches/0001-reparent-goini-library.patch b/debian/patches/0001-reparent-goini-library.patch
deleted file mode 100644
index 5ec34ce..0000000
--- a/debian/patches/0001-reparent-goini-library.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-Description: Use original glacjay/goini instead of fork
- Over time the original glacjay/goini repository has come up to date
- with the rakyll/goini fork.  This patch switches the dependency back
- to the original repository.
-Author: Tim Potter <tpot@hp.com>
-Bug: https://github.com/rakyll/globalconf/pull/13
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
-Index: golang-globalconf-0.0~git20140819/globalconf.go
-===================================================================
---- golang-globalconf-0.0~git20140819.orig/globalconf.go
-+++ golang-globalconf-0.0~git20140819/globalconf.go
-@@ -8,7 +8,7 @@ import (
- 	"path"
- 	"strings"
- 
--	ini "github.com/rakyll/goini"
-+	ini "github.com/glacjay/goini"
- )
- 
- const (
diff --git a/debian/patches/series b/debian/patches/series
index 0d1e943..e69de29 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +0,0 @@
-0001-reparent-goini-library.patch
diff --git a/globalconf.go b/globalconf.go
index 57d5dd4..c9b1ced 100644
--- a/globalconf.go
+++ b/globalconf.go
@@ -8,7 +8,7 @@ import (
 	"path"
 	"strings"
 
-	ini "github.com/rakyll/goini"
+	ini "github.com/glacjay/goini"
 )
 
 const (
@@ -98,14 +98,13 @@ func (g *GlobalConf) Delete(flagSetName, flagName string) error {
 	return nil
 }
 
-// Parses the config file for the provided flag set.
+// ParseSet parses the config file for the provided flag set.
 // If the flags are already set, values are overwritten
 // by the values in the config file. Defaults are not set
 // if the flag is not in the file.
 func (g *GlobalConf) ParseSet(flagSetName string, set *flag.FlagSet) {
 	set.VisitAll(func(f *flag.Flag) {
-		val := getEnv(g.EnvPrefix, flagSetName, f.Name)
-		if val != "" {
+		if val, ok := getEnv(g.EnvPrefix, flagSetName, f.Name); ok {
 			set.Set(f.Name, val)
 			return
 		}
@@ -117,7 +116,7 @@ func (g *GlobalConf) ParseSet(flagSetName string, set *flag.FlagSet) {
 	})
 }
 
-// Parses all the registered flag sets, including the command
+// Parse parses all the registered flag sets, including the command
 // line set and sets values from the config file if they are
 // not already set.
 func (g *GlobalConf) Parse() {
@@ -127,13 +126,12 @@ func (g *GlobalConf) Parse() {
 			alreadySet[f.Name] = true
 		})
 		set.VisitAll(func(f *flag.Flag) {
-			// if not already set, set it from dict if exists
+			// if not already set, set it from dict if ok
 			if alreadySet[f.Name] {
 				return
 			}
 
-			val := getEnv(g.EnvPrefix, name, f.Name)
-			if val != "" {
+			if val, ok := getEnv(g.EnvPrefix, name, f.Name); ok {
 				set.Set(f.Name, val)
 				return
 			}
@@ -156,10 +154,10 @@ func (g *GlobalConf) ParseAll() {
 }
 
 // Looks up variable in environment
-func getEnv(envPrefix, flagSetName, flagName string) string {
+func getEnv(envPrefix, flagSetName, flagName string) (string, bool) {
 	// If we haven't set an EnvPrefix, don't lookup vals in the ENV
 	if envPrefix == "" {
-		return ""
+		return "", false
 	}
 	// Append a _ to flagSetName if it exists.
 	if flagSetName != "" {
@@ -167,11 +165,13 @@ func getEnv(envPrefix, flagSetName, flagName string) string {
 	}
 	flagName = strings.Replace(flagName, ".", "_", -1)
 	flagName = strings.Replace(flagName, "-", "_", -1)
+	flagSetName = strings.Replace(flagSetName, ".", "_", -1)
+	flagSetName = strings.Replace(flagSetName, "-", "_", -1)
 	envKey := strings.ToUpper(envPrefix + flagSetName + flagName)
-	return os.Getenv(envKey)
+	return os.LookupEnv(envKey)
 }
 
-// Registers a flag set to be parsed. Register all flag sets
+// Register registers a flag set to be parsed. Register all flag sets
 // before calling this function. flag.CommandLine is automatically
 // registered.
 func Register(flagSetName string, set *flag.FlagSet) {
diff --git a/globalconf_test.go b/globalconf_test.go
index f36f74c..fce2cea 100644
--- a/globalconf_test.go
+++ b/globalconf_test.go
@@ -96,6 +96,22 @@ func TestParse_GlobalWithDottedFlagname(t *testing.T) {
 	}
 }
 
+// Given the need to test overwriting a flag with an environmental variable set to an empty string
+// Reset the flags and clear the env.
+// Set the env var for the c flag to an empty string.
+// Expect flagC to an empty string and not be the value Hello World from the INI file.
+func TestParse_GlobalWithEmptyValue(t *testing.T) {
+	resetForTesting("")
+
+	os.Setenv(envTestPrefix+"C", "")
+	flagC := flag.String("c", "", "")
+
+	parse(t, "./testdata/global.ini", envTestPrefix)
+	if got, want := *flagC, ""; got != want {
+		t.Errorf("got flag = %q, want empty string", got)
+	}
+}
+
 func TestParse_GlobalOverwrite(t *testing.T) {
 	resetForTesting("-b=7.6")
 	flagB := flag.Float64("b", 0.0, "")

Branch: pristine-tar

diff --git a/golang-github-rakyll-globalconf_0.0~git20180912.orig.tar.gz.delta b/golang-github-rakyll-globalconf_0.0~git20180912.orig.tar.gz.delta
new file mode 100644
index 0000000..5dfb10e
Binary files /dev/null and b/golang-github-rakyll-globalconf_0.0~git20180912.orig.tar.gz.delta differ
diff --git a/golang-github-rakyll-globalconf_0.0~git20180912.orig.tar.gz.id b/golang-github-rakyll-globalconf_0.0~git20180912.orig.tar.gz.id
new file mode 100644
index 0000000..2ce5bc5
--- /dev/null
+++ b/golang-github-rakyll-globalconf_0.0~git20180912.orig.tar.gz.id
@@ -0,0 +1 @@
+cd11b3e20e5fd5e9efb5420d65d7202db9c051a2

Branch: upstream

Tag: upstream/0.0_git20180912
diff --git a/.travis.yml b/.travis.yml
index fb9efcb..5b77ae6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,2 +1,2 @@
 language: go
-go: 1.2
+go: 1.5
diff --git a/README.md b/README.md
index dcbf4dd..363737c 100644
--- a/README.md
+++ b/README.md
@@ -86,7 +86,7 @@ Command line flags will override the environment variables.
 
 ~~~ go
 opts := globalconf.Options{
-	EnvPrefix: "MYAPP_",
+	EnvPrefix: "APPCONF_",
 	Filename:  "/path/to/config",
 }
 conf, err := globalconf.NewWithOptions(&opts)
diff --git a/globalconf.go b/globalconf.go
index 57d5dd4..c9b1ced 100644
--- a/globalconf.go
+++ b/globalconf.go
@@ -8,7 +8,7 @@ import (
 	"path"
 	"strings"
 
-	ini "github.com/rakyll/goini"
+	ini "github.com/glacjay/goini"
 )
 
 const (
@@ -98,14 +98,13 @@ func (g *GlobalConf) Delete(flagSetName, flagName string) error {
 	return nil
 }
 
-// Parses the config file for the provided flag set.
+// ParseSet parses the config file for the provided flag set.
 // If the flags are already set, values are overwritten
 // by the values in the config file. Defaults are not set
 // if the flag is not in the file.
 func (g *GlobalConf) ParseSet(flagSetName string, set *flag.FlagSet) {
 	set.VisitAll(func(f *flag.Flag) {
-		val := getEnv(g.EnvPrefix, flagSetName, f.Name)
-		if val != "" {
+		if val, ok := getEnv(g.EnvPrefix, flagSetName, f.Name); ok {
 			set.Set(f.Name, val)
 			return
 		}
@@ -117,7 +116,7 @@ func (g *GlobalConf) ParseSet(flagSetName string, set *flag.FlagSet) {
 	})
 }
 
-// Parses all the registered flag sets, including the command
+// Parse parses all the registered flag sets, including the command
 // line set and sets values from the config file if they are
 // not already set.
 func (g *GlobalConf) Parse() {
@@ -127,13 +126,12 @@ func (g *GlobalConf) Parse() {
 			alreadySet[f.Name] = true
 		})
 		set.VisitAll(func(f *flag.Flag) {
-			// if not already set, set it from dict if exists
+			// if not already set, set it from dict if ok
 			if alreadySet[f.Name] {
 				return
 			}
 
-			val := getEnv(g.EnvPrefix, name, f.Name)
-			if val != "" {
+			if val, ok := getEnv(g.EnvPrefix, name, f.Name); ok {
 				set.Set(f.Name, val)
 				return
 			}
@@ -156,10 +154,10 @@ func (g *GlobalConf) ParseAll() {
 }
 
 // Looks up variable in environment
-func getEnv(envPrefix, flagSetName, flagName string) string {
+func getEnv(envPrefix, flagSetName, flagName string) (string, bool) {
 	// If we haven't set an EnvPrefix, don't lookup vals in the ENV
 	if envPrefix == "" {
-		return ""
+		return "", false
 	}
 	// Append a _ to flagSetName if it exists.
 	if flagSetName != "" {
@@ -167,11 +165,13 @@ func getEnv(envPrefix, flagSetName, flagName string) string {
 	}
 	flagName = strings.Replace(flagName, ".", "_", -1)
 	flagName = strings.Replace(flagName, "-", "_", -1)
+	flagSetName = strings.Replace(flagSetName, ".", "_", -1)
+	flagSetName = strings.Replace(flagSetName, "-", "_", -1)
 	envKey := strings.ToUpper(envPrefix + flagSetName + flagName)
-	return os.Getenv(envKey)
+	return os.LookupEnv(envKey)
 }
 
-// Registers a flag set to be parsed. Register all flag sets
+// Register registers a flag set to be parsed. Register all flag sets
 // before calling this function. flag.CommandLine is automatically
 // registered.
 func Register(flagSetName string, set *flag.FlagSet) {
diff --git a/globalconf_test.go b/globalconf_test.go
index f36f74c..fce2cea 100644
--- a/globalconf_test.go
+++ b/globalconf_test.go
@@ -96,6 +96,22 @@ func TestParse_GlobalWithDottedFlagname(t *testing.T) {
 	}
 }
 
+// Given the need to test overwriting a flag with an environmental variable set to an empty string
+// Reset the flags and clear the env.
+// Set the env var for the c flag to an empty string.
+// Expect flagC to an empty string and not be the value Hello World from the INI file.
+func TestParse_GlobalWithEmptyValue(t *testing.T) {
+	resetForTesting("")
+
+	os.Setenv(envTestPrefix+"C", "")
+	flagC := flag.String("c", "", "")
+
+	parse(t, "./testdata/global.ini", envTestPrefix)
+	if got, want := *flagC, ""; got != want {
+		t.Errorf("got flag = %q, want empty string", got)
+	}
+}
+
 func TestParse_GlobalOverwrite(t *testing.T) {
 	resetForTesting("-b=7.6")
 	flagB := flag.Float64("b", 0.0, "")

Publish Blockers

  • ☑ run was successful
  • ☑ package has not been removed from the archive
  • ☒ command changed from DEB_UPDATE_CHANGELOG=leave deb-new-upstream --snapshot --refresh-patches to DEB_UPDATE_CHANGELOG=auto deb-new-upstream --snapshot --refresh-patches
  • ☒ not yet reviewed, but review needed
  • ☑ 0 publish attempts so far. not currently attempting to back off
  • ☒ merge proposals for the package maintainer are currently being rate-limited (open: 1135, max open: 200)
  • ☑ change set 6654cfc8-3bd5-41fe-b3ff-86a134b8fb49 is ready

Resulting package

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-snapshots golang-github-rakyll-globalconf-dev

Lintian Result

Full worker log Full build log