Replies: 2 comments
-
|
+1 for Idea 2. Adding a method like |
Beta Was this translation helpful? Give feedback.
-
|
One nit: I'd love to have something that maps to the URLs from https://gocloud.dev/howto/sql/ - but that's probably a lost case anyway. For a migration away from Config, idea 2 is definitely better. It could also support a solution to Problem 3 with e.g. Sounds good to me - only the I could think of one other way to handle this - that cuts down the mysql package statements: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Current Config object have several issues.
Params map[string]stringthat makes fixing Is it possible to execute set variable sequentially? #1455 difficult.The second problem will growth forever. We may add
Compression boolandCompressionMethod []strlater. To stop making Config bigger and more complex, I am considering two options:Idea 1: Add methods to
*ConfigThis is simpler approach. Keep existing Config fields but stop adding public fields anymore.
We will add methods to Config instead:
func (c *Config) SetCompression(enable bool)func (c *Config) SetTimeTruncate(d time.Duration)(revert TimeTruncate field added recently but never released yet)Example:
Idea 2: Use "Functional Option Pattern"
This is similar to the previous, but add one
func (c *Config) SetOptions(option...)method instead of manySet***()methods and have many FOP functions like:func Compression(enable bool) optionfunc TimeTruncate(d time.Duration) optionExample:
Idea 1 is simpler. But with Idea 2, we can reuse option functions in new API and stop using Config completely like this:
How do you think? @shogo82148, @arnehormann
Beta Was this translation helpful? Give feedback.
All reactions