Git Product home page Git Product logo

Comments (3)

object88 avatar object88 commented on July 28, 2024

Complete this issue before #2 , #7, #14.

from options.

object88 avatar object88 commented on July 28, 2024

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.

object88 avatar object88 commented on July 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.