Comments (3)
Hi,
Confirmed that it is not an issue with endless. Minimal test code:
Recommended directory structure:
test/
main.go
testlib/
testlib.go
Then in test
:
go build -o test test.go
./test -param
(application flags are illegal)./test -libarg
(library flags also illegal)
I'm certain this arises from the use of different flag libraries, but I am unable to recommend a fix at this time.
from flag.
A library should not mandate the user interface of an application unless it is an UI library.
The flag
package is a UI library, the testlib
package in your example is not.
It is best practice to pass options in libraries through a public function. Take for example the database/sql
package:
import "database/sql"
func main() {
db, err := sql.Open("postgres", "user=pqgotest dbname=pqgotest sslmode=verify-full")
…
from flag.
Hi,
The code illustrates that the flag library hijacks the interpretation of flags globally, preventing it from being used with other (possibly UI, according to your terminology) libraries that access flags.
I can accept that this is a fundamental design flaw of the flags (both core and namsral versions) libraries, which access shared global state and interpret it as a rule set. It prevents composition of UI libraries for doing things like what endless
attempts, which is attempting to re-fork the executable and pass in an argument indicating a restart rather than a virgin launch. Endless does not use namsral/flag for this; it uses the core library. The core library and namsral/flag can not both be used within the same application. It is as if using a Postgres SQL DB library implicitly prevented you from using a MySQL DB library because they both accessed some global shared state and read the configurations as being incompatible.
So: while I still see this as a fundamental design flaw, I don't disagree with closing the ticket as it isn't the namsral/flag's design flaw. It's just unfortunate that it inherits the flaw.
from flag.
Related Issues (20)
- `go test -v` stops working HOT 4
- using config file by default HOT 6
- Execution with -h should just print the usage instruction and exit HOT 2
- print error from config file parsing by default HOT 1
- Parse behaviour is wrong when flag contains "-" HOT 1
- lowercase environment variables HOT 1
- prefix for environment variables HOT 6
- Add camel case flag name example to readme
- type alias for Value, Getter etc.
- Is there a way to disable the ConfigFlagname of a FlagSet?
- Release new version
- Support for fixed-size integer types
- Reading individual values from files (eg. docker secrets) HOT 3
- Support for required flag and Default should be optional
- Out of Sync with latest go version - Newer fork available jnovack/flag HOT 2
- Support Multi Value Flags in Config
- Still Maintained?
- Config file parse failure "configuration variable provided but not defined" is not visible to application HOT 2
- Required environment variables is a regression HOT 6
- Running go test with any of the standard flags throws an "flag provided but not defined:" error HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flag.