Re: [go-nuts] Is it acceptable to make the optional parameter as varargs

2020-05-24 Thread Amarjeet Anand
Thanks Robert for the nice idea. Using builder pattern to set options didn't come to my mind. Looks really clean. On Mon, 25 May, 2020, 10:55 AM robert engels, wrote: > I think the Builder pattern is easier than this, and it retains the > property of both ‘config struct’ and ‘multiple args’ vers

[go-nuts] Re: Is there a way to create a global variable inside go routine stack? so that i can access any time, without passing around between methods/functions. Crazy thought !!!..

2020-05-24 Thread adithyasashasai
Yeah this works, but you can say this as workaround, what i really want is, does native go support? if not why? On Monday, May 25, 2020 at 7:57:17 AM UTC+5:30, tokers wrote: > > You may try to inspect this go package: https://github.com/jtolio/gls > -- You received this message because you are

Re: [go-nuts] Is it acceptable to make the optional parameter as varargs

2020-05-24 Thread robert engels
I think the Builder pattern is easier than this, and it retains the property of both ‘config struct’ and ‘multiple args’ versions that the implementation can re-order and validate option in aggregate easier - but most of all is doesn’t pollute that package with top-level public functions. The bu

Re: [go-nuts] Re: Need help with go modules

2020-05-24 Thread Jan Mercl
On Sun, May 24, 2020 at 6:58 AM Henry wrote: > To create a Go Module, step inside your project folder, and type go mod init > where is the qualified name of your project. For > instance, if you want to call your project "github.com/henry/myproject", then > inside your myproject folder, type g

Re: [go-nuts] Is it acceptable to make the optional parameter as varargs

2020-05-24 Thread Amarjeet Anand
Thanks James for your response and the amazing posts. On Mon, May 25, 2020 at 9:01 AM James wrote: > This reminds me of functional options which I think are used quite widely > for this purpose. > > See > https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis > and > https://gi

[go-nuts] time.Ticker's behavior

2020-05-24 Thread Kai Zhang
Hello, I'm using ticker to do some batch works.But I found why tickers runs not as expect.why the second ticker is 100 Millisecond.code is here thanks, zhangkai 2020-05-25 -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] Is it acceptable to make the optional parameter as varargs

2020-05-24 Thread James
This reminds me of functional options which I think are used quite widely for this purpose. See https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis and https://github.com/tmrts/go-patterns/blob/master/idiom/functional-options.md On Mon, 25 May 2020 at 14:57, Amarjeet Anand w

[go-nuts] Is it acceptable to make the optional parameter as varargs

2020-05-24 Thread Amarjeet Anand
Is it acceptable to make the optional parameter as varargs? I wrote code in my package like ... package backoff func New(options ...Options) *backOff { backOff := defaultBackOff() if len(options) == 0 { return backOff } // override default values if len(options) > 1 {

[go-nuts] Re: Is there a way to create a global variable inside go routine stack? so that i can access any time, without passing around between methods/functions. Crazy thought !!!..

2020-05-24 Thread tokers
You may try to inspect this go package: https://github.com/jtolio/gls -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To

Re: [go-nuts] Re: Tracking down RSS growth in cgo library

2020-05-24 Thread Justin Israel
On Mon, May 25, 2020, 7:12 AM Ian Lance Taylor wrote: > On Sat, May 23, 2020 at 8:39 PM Justin Israel > wrote: > > > > On Sat, May 23, 2020 at 5:19 PM Justin Israel > wrote: > >> > >> I've been working to track this down for 2 days now and I'm just taking > a long shot to see if anyone might ha

[go-nuts] Re: Is there a way to create a global variable inside go routine stack? so that i can access any time, without passing around between methods/functions. Crazy thought !!!..

2020-05-24 Thread adithyasashasai
if i am not wrong, Even the main itself is a go routine, which have global variables? On Monday, May 25, 2020 at 12:23:49 AM UTC+5:30, Saied Seghatoleslami wrote: > > Variable scope is a textual (special if you like) concept. Go routines > are a temporal concept. Does it make sense to think

Re: [go-nuts] Re: Tracking down RSS growth in cgo library

2020-05-24 Thread Ian Lance Taylor
On Sat, May 23, 2020 at 8:39 PM Justin Israel wrote: > > On Sat, May 23, 2020 at 5:19 PM Justin Israel wrote: >> >> I've been working to track this down for 2 days now and I'm just taking a >> long shot to see if anyone might have a new idea for me. >> My cgo-based bindings library seems to have

[go-nuts] Is there a way to create a global variable inside go routine stack? so that i can access any time, without passing around between methods/functions. Crazy thought !!!..

2020-05-24 Thread saied
Variable scope is a textual (special if you like) concept. Go routines are a temporal concept. Does it make sense to think about a global variable in this way? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group

[go-nuts] ssh server: requiring both public key auth and keyboard-interactive auth?

2020-05-24 Thread Brian Candler
When writing an ssh server with golang.org/x/crypto/ssh, is there a way to require both public key *and* keyboard interactive authentication for the same login? With openssh server you can configure: AuthenticationMethods publickey,keyboard-interactive:pam and the client shows: ... debug1: Aut

[go-nuts] Instrumenting in Go and code generation

2020-05-24 Thread Sergey Kamardin
Hello Gophers, I just wanted to share an article and open source tool that I've finished recently. They both are about instrumenting (aka tracing) Go components. Article covers some background on it, while tool helps to generate boilerplate code to easily provide tracing hooks in your structs. A