github / go-opstocat Goto Github PK
View Code? Open in Web Editor NEWDEPRECATED
License: MIT License
DEPRECATED
License: MIT License
I think string only is probably wise, since you could conceivably stick anything in there. Perhaps we can validate the type or catch the panic and show a useful error message.
Example code:
package main
import (
"github.com/github/go-opstocat"
"os"
)
type Configuration struct {
TestVal int `json:"TEST_VAL"`
*opstocat.Configuration
}
func (c *Configuration) OpstocatConfiguration() *opstocat.Configuration {
return c.Configuration
}
func (c *Configuration) SetupLogger() {}
func main() {
wd, err := os.Getwd()
if err != nil {
panic(err)
}
inner := opstocat.NewConfiguration(wd)
inner.App = "test"
c := &Configuration{
Configuration: inner,
}
opstocat.ReadEnv(c)
opstocat.SetupLogger(c)
}
Result:
rubyist:octotest scott$ TEST_VAL=100 ./octotest
panic: reflect: call of reflect.Value.SetString on int Value
goroutine 16 [running]:
runtime.panic(0x278ae0, 0xc208043880)
/usr/local/go/src/pkg/runtime/panic.c:279 +0xf5
reflect.flag.mustBe(0x26, 0x18)
/usr/local/go/src/pkg/reflect/value.go:307 +0x8c
reflect.Value.SetString(0x21f3c0, 0xc208000ad0, 0x0, 0x26, 0x7fff5fbff12c, 0x3)
/usr/local/go/src/pkg/reflect/value.go:1691 +0x3e
github.com/github/go-opstocat.readEnvConfig(0x2a1640, 0xc208000ad0)
/Users/scott/src/gocode/src/github.com/github/go-opstocat/config.go:95 +0x2d6
github.com/github/go-opstocat.ReadEnv(0x5127b0, 0xc208000ad0)
/Users/scott/src/gocode/src/github.com/github/go-opstocat/config.go:58 +0x67
main.main()
/Users/scott/src/gocode/src/github.com/github/octotest/octotest.go:31 +0x10f
goroutine 19 [finalizer wait]:
runtime.park(0x14550, 0x466fd0, 0x465ac9)
/usr/local/go/src/pkg/runtime/proc.c:1369 +0x89
runtime.parkunlock(0x466fd0, 0x465ac9)
/usr/local/go/src/pkg/runtime/proc.c:1385 +0x3b
runfinq()
/usr/local/go/src/pkg/runtime/mgc0.c:2644 +0xcf
runtime.goexit()
/usr/local/go/src/pkg/runtime/proc.c:1445
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.