Comments (7)
I like Value. It feels like time.Time{}
, big.Int{}
, etc to me. But, I'm not hugely opinionated - both seem pretty readable imo.
from wire.
@enocom, @tbpg, @jadekler any thoughts?
from wire.
I'm worried about the following edge cases in wire.Value
as it exists now:
- Referring to a package variable that changes. The declaration makes it seem like it would take on the value from initialization time, but it's actually evaluated when the injector is called (mildly surprising).
- There's no way to write an interface-nil expression in a way that could be preserved at runtime. This limits Wire provider sets to being compile-time only.
from wire.
#1 is a bummer, I agree. Could you elaborate on #2? I don't fully grok.
from wire.
Consider an implementation of Wire that does not do code generation, but instead relies on reflection. (There are no plans to do so, but it would be nice to allow this to permit interoperability with other DI libraries.) If you write goose.Value(MyInterface(nil))
to satisfy a dependency on MyInterface
, it will work in the gowire
code gen tool, but the type information is lost at runtime (this is a subtle point, see Francesc's Understanding Nil for a refresher).
from wire.
Do we not have the same problem regardless of the name? I'm in fairly-unfamiliar and barely-grokking territory though so I may not be the best reviewer heh.
from wire.
I discussed this with @rsc and he came up with a better idea to preserve wire.Value
while fixing the more confusing semantics. I've captured this in #104; I'm closing this issue out in favor of that one.
from wire.
Related Issues (20)
- function generated by Wire_gen.go "Cannot find declaration to go to" by Golang JetBrains but still run success HOT 5
- Calling wire.Build with a provider set from a structure variable (For modular buildings)
- wire `sync.Map` throw error HOT 2
- I has bean tried for two days, but failed. I define four struct and it's constructor, I define a init function in wire.go, but I can
- I can't use the init function which from my wire.go in my main.go HOT 3
- wire.NewSet support generics HOT 1
- internal/wire: update the path of wire which go generate run wire cmd
- Wire: not enough arguments in call to xxx
- is wire.FieldsOf support any field ? HOT 2
- Support for request scoped DI code generation HOT 2
- Injecting the subpackage into the parent package results in the error "no provider found for invalid type". HOT 3
- How to use wire.Bind() if concrete implementation is resolved at runtime? HOT 2
- please create new tag for 0675cdc
- Crashing with Go 1.22 HOT 3
- go generate ./... no longer works with go 1.22.0 and wire 0.6.0 HOT 3
- go build -mod=vendor ./cmd/wire doesn't work after update to 0.6.0
- go: -mod may only be set to readonly or vendor when in workspace mode, but it is set to "mod" HOT 2
- Sometimes it succeeds, sometimes it fails HOT 1
- Cleanup functions should return erors
- wire does not work with go 1.23.0
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 wire.