Profile cover photo
Profile photo
Mark Petrovic
276 followers
276 followers
About
Mark's interests
Mark's posts

Post has attachment

Good day. I am struggling with an embedded pointer issue that the community may be able to help me with.

I have a "production" struct named productionWrapper that has a field that is a pointer to what amounts to a network client. That field is named afield. In production, this field is initialized in a simple constructor function.

However, in a unit test, I wish to mock one of the functions on embedded pointer type. This is where I am struggling, specifically with a compilation error around type assignments. Here is the sample code:

https://play.golang.org/p/5ghS4N684K

My type understanding is clearly weaker than I want it to be, and I welcome feedback on how to make this work or whether it's even possible to mock in this way.

Thank you.

Post has shared content

Post has shared content

Post has attachment
My completed Elecraft K1 CW transceiver.

#elecraft   #amateurradio  
Photo

Post has shared content

"We can solve the problem of a fixed filter pass band by adding a
variable oscillator, another mixer, and another image-reject filter.
This is the superheterodyne receiver, arguably the most important
invention in the history of communications." David B. Rutledge, The
Electronics of Radio

I'm struggling with a bit of custom JSON marshalling and hope someone here can help.

I have this: https://play.golang.org/p/5sex73IvXi

which outputs this

{
   "status": "OK",
   "Dependencies": {
      "rabbit": {
         "status": "OK"
      },
      "zookeeper": {
         "status": "DOWN"
      }
   }
}

But what I need is this, with the "Dependencies" level elided, leaving just the map embedded in the output:

{
   "status": "OK",
   "rabbit": {
      "status": "OK"
   },
   "zookeeper": {
      "status": "DOWN"
   }
}

I experimented with an intermediary struct wrapping a map[string]Status that implemented json.Marshaler, and could produce different output, but not the output I wanted.

Anyone?

Thank you.

Post has attachment
Hi.  May I get some review on this small snippet of code?

https://play.golang.org/p/9C3LVXcuiZ

I believe the access to the map m needs to be protected by a mutex, but I'm not sure.  

Actually, I'm not confident this code even works, when, say, a goutine gets the read lock, gets interrupted, and one that requires the write lock gains control.

Thanks.

Post has attachment
Wait while more posts are being loaded