Here is a #golang challenge for you! πŸ€“
Without modifying my package named "puzzler", can you create, in the main function, a variable of (non-exported) type puzzler.config? Playground: https://go.dev/play/p/hSSRfbZbjKK
I'll post a solution tomorrow. πŸ˜‰
Go Playground - The Go Programming Language

@jub0bs Depends on how you define "without modifying my package"
@hexaheximal You can add whatever you want above line 9 (on my screenshot), nothing on or below it. Is that clearer?

@jub0bs somewhat.

The solution I'm thinking of would be to create a new file in the `puzzler` directory that exports a function to create it.

@hexaheximal Not allowed. Only modify the main package, nothing else. πŸ˜‰β€‹

@jub0bs found a solution using reflection!

Link: https://go.dev/play/p/KgUjXgbl0eU

I wonder if we can use the `WithTimeoutMs` without reflection to get the desired type. Would gladly take a look at your solution.

Go Playground - The Go Programming Language

@babariviere Nice! Reflection is indeed one possible approach. How about with generics only (no reflection)?

@jub0bs Ah got it!

So this is what you expected?

https://go.dev/play/p/VuJGqTLeSE9

Go Playground - The Go Programming Language

@babariviere Yes, well done; you don't even need to call f, though.

I'll talk about what this implies in a future post.

@jub0bs Now that you say it, it’s logic haha.

Will look into it!

@jub0bs Took me a moment to figure it out πŸ˜„ https://go.dev/play/p/bNQT5vy9F3u
Go Playground - The Go Programming Language

jub0bs (@[email protected])

@[email protected] Yes, well done; you don't even need to call f, though. I'll talk about what this implies in a future post.

Infosec Exchange