[go-nuts] Re: Exporting and renaming

2019-05-03 Thread michael . f . ellis
Oops, meant to type GoRename instead of GoVet On Friday, May 3, 2019 at 4:05:59 PM UTC-4, michae...@gmail.com wrote: > > Thanks, Tamás. That worked. Still a bit tedious since GoVet was taking > about 6 seconds to rename all the instances of each struct field. But it's > done now. > > On

[go-nuts] Re: Exporting and renaming

2019-05-03 Thread michael . f . ellis
Thanks, Tamás. That worked. Still a bit tedious since GoVet was taking about 6 seconds to rename all the instances of each struct field. But it's done now. On Friday, May 3, 2019 at 3:58:34 PM UTC-4, Tamás Gulácsi wrote: > > Rename the struct fields first, then move it to its own package.

[go-nuts] Exporting and renaming

2019-05-03 Thread michael . f . ellis
I want to make part of my main package into an internal package. It's only one file and I only need to export a single struct type and one function. Seemed easy enough -- just git mv the file to ../internal/ and use GoRename in vim. Problem is that all the struct fields are lowercase and

Re: [go-nuts] Concurrency safe struct access

2019-04-15 Thread michael . f . ellis
FWIW, here's the pattern I've settled on for my actual application. https://play.golang.org/p/OBVsp-Rjknf It uses sync.Mutex only and includes the mutex as a member of the guardedState struct. The deciding factor was that my industrial control application has a very large state struct with

Re: [go-nuts] Concurrency safe struct access

2019-04-14 Thread michael . f . ellis
I found a good discussion in the FAQ that explains the problem clearly. https://golang.org/doc/faq#methods_on_values_or_pointers I think the mutex is needed on the update function with or without the use of sync/atomic. The atomic guards the Load and the Store but the func is operating on the

Re: [go-nuts] Concurrency safe struct access

2019-04-14 Thread michael . f . ellis
Good to know about not needing sync/atomic. I used a pointer to an externally defined mutex because an answer I found on StackOverflow recommended doing that. However, on looking at my application more closely I think you're right about putting it inside the struct. On Sunday, April 14, 2019

[go-nuts] Concurrency safe struct access

2019-04-14 Thread michael . f . ellis
https://play.golang.org/p/6aQYNjojyBD I'm clearly missing something about the way sync.Mutex and atomic.Value work in Go. I'm attempting to write a pair of concurrency safe methods, load() and update(), for accessing a struct. The struct is stored as an atomic.Value and accessed with

[go-nuts] Updating a struct from goroutines

2018-09-25 Thread michael . f . ellis
Hi, new gopher here. I considered asking this on SO, but they (rightly, IMO) discourage "Is this a good way to do it?" questions. Hope that's ok here. By way of background, I'm porting a largish industrial control application from Python to Go. The Python version uses multiple processes