[go-nuts] Go modules and project-local imports.

2019-12-03 Thread Andrei Avram
Are you looking for replace and v0.0.0? https://github.com/golang/go/wiki/Modules#when-should-i-use-the-replace-directive -- 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

Re: [go-nuts] Workaround for missing RWMutex.Try*Lock()

2019-12-03 Thread robert engels
You actually only need a cas and a condition variable (technically the condition in Go requires a backing lock, but if you have wait/notify it isn’t needed). You can read this https://code.woboq.org/userspace/glibc/nptl/pthread_rwlock_common.c.html

Re: [go-nuts] CGO - Passing pointer to C

2019-12-03 Thread Ian Lance Taylor
On Tue, Dec 3, 2019 at 7:20 PM Robert Johnstone wrote: > > The section on passing pointer to C in the cgo documentation is quite clear > that letting C hold pointer to Go memory is not allowed. I'd like to better > understand the limitation. Frankly, because of the architecture of a system >

[go-nuts] CGO - Passing pointer to C

2019-12-03 Thread Robert Johnstone
Hello, The section on passing pointer to C in the cgo documentation is quite clear that letting C hold pointer to Go memory is not allowed. I'd like to better understand the limitation. Frankly, because of the architecture of a system I'm working on, the inability to transport pointers is

Re: [go-nuts] Workaround for missing RWMutex.Try*Lock()

2019-12-03 Thread burak serdar
On Tue, Dec 3, 2019 at 6:54 PM Liam wrote: > > Busy means would-block, yes. > > Burak thanks, but that doesn't work for read-lock. You are right, I keep reading it as Lock instead of RLock. Here's another attempt at solving it: https://play.golang.org/p/az3hnyIwe47 > > On Tuesday, December

Re: [go-nuts] Workaround for missing RWMutex.Try*Lock()

2019-12-03 Thread Liam
Busy means would-block, yes. Burak thanks, but that doesn't work for read-lock. On Tuesday, December 3, 2019 at 5:39:48 PM UTC-8, Robert Engels wrote: > > It depends then, because technically the Go RW lock queues readers behind > a waiting writer so “busy” is somewhat undefined. If “busy”

Re: [go-nuts] Workaround for missing RWMutex.Try*Lock()

2019-12-03 Thread Robert Engels
It depends then, because technically the Go RW lock queues readers behind a waiting writer so “busy” is somewhat undefined. If “busy” means “would block” you can still do it - I’ll post the code tonight. > On Dec 3, 2019, at 6:49 PM, Robert Engels wrote: > > I would use an atomic and a lock

Re: [go-nuts] Workaround for missing RWMutex.Try*Lock()

2019-12-03 Thread burak serdar
On Tue, Dec 3, 2019 at 6:31 PM Liam wrote: > > Erm... not seeing how cas works to try a read-lock, which admits multiple > callers... Something like this should work: TryLock: if CompareAndSwap(,0,1) { door.Lock() return true } return false Unlock: door.Unlock() Store(,0) > > On

Re: [go-nuts] Workaround for missing RWMutex.Try*Lock()

2019-12-03 Thread Liam
Erm... not seeing how cas works to try a read-lock, which admits multiple callers... On Tuesday, December 3, 2019 at 5:12:08 PM UTC-8, Robert Engels wrote: > > Can’t code on the phone but a cas on the atomic then take the lock. But if > you never need to block you don’t even need the lock. > >

Re: [go-nuts] Workaround for missing RWMutex.Try*Lock()

2019-12-03 Thread Robert Engels
Can’t code on the phone but a cas on the atomic then take the lock. But if you never need to block you don’t even need the lock. > On Dec 3, 2019, at 6:52 PM, Liam Breck wrote: > >  > Which looks like...? > >> On Tue, Dec 3, 2019, 4:50 PM Robert Engels wrote: >> I would use an atomic and a

Re: [go-nuts] Workaround for missing RWMutex.Try*Lock()

2019-12-03 Thread Liam Breck
Which looks like...? On Tue, Dec 3, 2019, 4:50 PM Robert Engels wrote: > I would use an atomic and a lock instead of two locks. > > > On Dec 3, 2019, at 6:35 PM, burak serdar wrote: > > > > On Tue, Dec 3, 2019 at 5:21 PM Liam Breck > wrote: > >> > >> I have a problem that is trivially solved

Re: [go-nuts] Workaround for missing RWMutex.Try*Lock()

2019-12-03 Thread Robert Engels
I would use an atomic and a lock instead of two locks. > On Dec 3, 2019, at 6:35 PM, burak serdar wrote: > > On Tue, Dec 3, 2019 at 5:21 PM Liam Breck wrote: >> >> I have a problem that is trivially solved via >> >> door sync.RWMutex >> >> func Reader() T { >> if !door.TryRLock() { //

Re: [go-nuts] Workaround for missing RWMutex.Try*Lock()

2019-12-03 Thread burak serdar
On Tue, Dec 3, 2019 at 5:21 PM Liam Breck wrote: > > I have a problem that is trivially solved via > > door sync.RWMutex > > func Reader() T { >if !door.TryRLock() { // missing in stdlib :-( > return busy >} >defer door.RUnlock() >... > } > > func Writer() { >door.Lock()

[go-nuts] Workaround for missing RWMutex.Try*Lock()

2019-12-03 Thread Liam Breck
I have a problem that is trivially solved via door sync.RWMutex func Reader() T { if !door.TryRLock() { // missing in stdlib :-( return busy } defer door.RUnlock() ... } func Writer() { door.Lock() defer door.Unlock() ... } How does one achieve this in Go? -- You

[go-nuts] Go modules and project-local imports.

2019-12-03 Thread Bruno Albuquerque
When working with Go modules, what is the idiomatic way to deal with project-local imports (i.e. directories that are not supposed to be checked out separately from everything else. A simple example would be something like this: project/ library.go example/ example.go Here,

Re: [go-nuts] ask for you help about cgo and interface

2019-12-03 Thread Ian Lance Taylor
On Tue, Dec 3, 2019 at 12:29 AM FAN DEAR wrote: > > typedef struct { void *t; void *v; } GoInterface; > > > What is *t and *v? See https://research.swtch.com/interfaces. Ian > 在 2019年12月3日星期二 UTC+8上午2:41:36,Ian Lance Taylor写道: >> >> On Mon, Dec 2, 2019 at 9:57 AM FAN DEAR wrote: >> > >> > >>

[go-nuts] [ANN] grugen: a code generator for control break logic

2019-12-03 Thread HaWe
At work back in the 80s and 90s we used a 4GL developement tool (with name Delta/ADS) to generate Cobol code. The most frequently used part of it was a generator fo control break logic, meaning Cobol programs that processed sorted sequential input data. Now I built something similar (simpler)

Re: [go-nuts] ask for you help about cgo and interface

2019-12-03 Thread FAN DEAR
typedef struct { void *t; void *v; } GoInterface; What is *t and *v? 在 2019年12月3日星期二 UTC+8上午2:41:36,Ian Lance Taylor写道: > > On Mon, Dec 2, 2019 at 9:57 AM FAN DEAR > > wrote: > > > > > > How to use add2 function, i am very troubled. > > On this mailing list please post code as ordinary