Comments (3)
Complete this issue before #2 , #7, #14.
from options.
Field-based options to consider:
- name
- ignore
- private
Only one of these particular options would be applicable at a time. If later options are feasible, they can be comma-separated. Name would be followed by an equals and the new func name, while ignore and private would be stand-alone toggles.
Example:
type FooOption struct {
a string `options:"name=AssignA"` // Generates `AssignA`
b int `options:"private"` // Generates `setB`
c bool `options:"ignore"` // Does not generate a func
}
from options.
Consider the importance of this vs. allowing for configuration across the whole struct. Tags are only allowed on fields, and not the struct itself. This means that we cannot create struct-specific defaults. As a concrete example, we cannot set a default func prefix (i.e., "Assign" instead of "Set").
// FooOptions are all of the options for `Foo`
// +options:"prefix=Assign"
type FooOptions struct {
// +options:"ignore"
a string
// +options:"private"
B int
c int
}
This would generate the follow:
func (fo *FooOptions) assignB(b int) options.OptionFunc {
// etc.
}
func (fo *FooOptions) AssignB(c int) options.OptionFunc {
// etc.
}
This appears to be a non-standard way of doing things in Go. But it's not unheard of. Correction: the idea is supported by Russ Cox (at least as of 2014):
Different programs process different special comments: the go command processes //go:generate, the compiler processes //go:noescape, third-party tools can process //other:thing, and so on. No program knows the full set of directives. All the more reason to make them ordinary comments.
from options.
Related Issues (15)
- Do not attempt to recreate methods HOT 1
- Comment-based directive to make private
- Test with linting tools
- Test with non-basic types
- Test end-to-end generation
- Gracefully halt if target struct already has `Apply` func
- Comment-based directive to ignore
- Annotation to specify target struct HOT 1
- Test with `go:generate`
- Test nested struct
- Benchmark and document impact of using reflection
- Document date of generation in generated code HOT 1
- Comment-based directive to set specific `OptionFunc` name
- Augment build to embed build information in binary
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 options.