Attempting to iterate over a map[string]interface{} type in GoLang to retrieve the field key’ed as ‘status’. Known: the interface{} type for the value is _either_ a string OR another map[string]interface{}…

Unsuccessful attempt:


func (paramToCheck string) findKey(keyToCheck string) (string, bool) {
        return keyToCheck, (keyToCheck == paramToCheck)
}

func (paramToCheck map[string]interface{}) findKey(key string) (string, bool) {
        for key, value := range paramToCheck {
                foundValue, found := value.findKey(key)
                if found {
                        return foundValue, true
                }
        }
        return key, false
}

func (val interface{}) findKey(key string) (string, bool) {
        fmt.Println("Unable to find value...")
        return key, false
}

Results of go install:


./parseResult.go:55: invalid receiver type map[string]interface {} (map[string]interface {} is an unnamed type)
./parseResult.go:57: value.findKey undefined (type interface {} is interface with no methods)
./parseResult.go:65: findKey redeclared in this block
previous declaration at ./parseResult.go:55
./parseResult.go:65: invalid receiver type interface {} (interface {} is an unnamed type)
./parseResult.go:78: value.findKey undefined (type interface {} is interface with no methods)

Back to the drawing board… The other day, I also tried a switch statement approach like the below…


switch val := v.(type) {
                case string:
                        fmt.Println(val)
                        checkVal = val
                case map[string]interface{}:
                        fmt.Println("Found interface...")
                        for k, v := range val {
                                switch val := v.(type) {
                                case string:
                                        fmt.Println(val)
                                        checkPhase(k, checkVal)
                                case map[string]interface{}:
                                        fmt.Println("Found ANOTHER interface map...")
                                }
                        }

                }

I ended up realizing I needed something a bit more recursive, since I know there are at least 3 levels of map[string]interface{} gook in my data set.

Looking at what I’ve got, suspect what I need to is blend the function approach with the switch statement approach and duck the attempt to add polymorphic methods to string.. Huh. Why didn’t I see that before starting this blog post?? Good blog audience who hasn’t even seen this. Just attempting to describe this to you may have got me a solution. Saving my draft here and trying it out…

OK… results that did what I want… Bingo!!!


func findKey(key string, value interface{}, checkKey string) (string, bool) {
        fmt.Printf("findKey for %v against checkKey %v\n", key, checkKey)
        switch val := value.(type) {
        case string:
                return val, (key == checkKey)
        case map[string]interface{}:
                for newKey, newValue := range val {
                        foundValue, found := findKey(newKey, newValue, checkKey)
                        if found {
                                return foundValue, found
                        }
                }
        }
        return "", false
}

func ParseJobState(params map[string]interface{}) []JobOutcome {

        // Example: non-compiling code: [1]JobOutcome != []JobOutcome.
        // Size of array is included in its type.  Use slices instead
        //outcomesArray := [...]JobOutcome{firstOutcome}
        //return outcomesArray

        for key, value := range params {
                statusValue, found := findKey(key, value, "status")
                if found {
                        fmt.Printf("Status found: %v\n", statusValue)
                        break
                }
        }

}

[BLOGGER NOTE: Just added the Preserve Code Formatting plugin to WordPress – code blocks like the above work MUCH more nicely now… Thanks to http://blog.templatemonster.com/2011/04/15/wordpress-plugins-code-snippets-displaying/ for helping find a solution…]

+1 for hardware: got my Raspberry Pi using my MacBook’s Wifi connection for its Internet, as well as the Macbook as a DHCP. Outcome: my pi now has an IP address I can grab from the Mac, which means I don’t need a separate monitor and keyboard hooked up to the pi to be able to do things.. I can ssh into the pi and effectively use my laptop as my keyboard and monitor. And my pi can still reach out to the Internet, which will mean it’ll be able to access a remote Jenkins server, even if remote just means hosted off the Mac. These are important things to consider when dealing with a conference where you’ll be working off of an unknown WiFi….

-1 for software… was trying to get a feature done for our sprint demo and just didn’t quite get it there. Number of reasons impacting, some of them a result of other folks’ efforts, but the net is that tomorrow’s demo won’t work end-to-end.

If my +1 and -1 were merge request voting, I’d be done for on my team.. -1 is a reject status, regardless of how many plus ups balance it out. But since this is the realm of humans, I’ll count the day at worst a draw.

Caught a post in my Twitter feed called “Couch Con’ing O’Reilly Fluent Conference 2016”… David couldn’t go to Fluent – web development conference this year, so he listed the sessions he would have gone to and indicated why. It made me think of how I approach conferences. Most of the conferences I want to go to, I can’t go to – there’s not enough time and money loosely available for me to hit up everything I’d like. But I’ll often do what David’s done and survey the session list for a conference… my intent is to see what the general themes are, and see if there’s anything that comes up enough to either have me try to find some replay of that session or go research the topic on my own. Couple of hints on the approach for replaying sessions or otherwise getting access to information a speaker will present:
1) O’Reilly in particular tapes many of its conferences and makes the sessions available to its Safari subscribers. I’ve caught sessions from Strata, Cultivate, OSCON, and Fluent, all through paying one fee per year for unlimited video access. Even for conferences I attend, I can’t hit every session I want – this lets me go back and catch all the topics I manage to find time to fit in.
2) Some conferences (Google I/O, Oculus, Samsung Developer) are kind enough to set up YouTube channels, with videos per presentation.
3) Conference schedules list speakers. Speaker bios list blog pages and Twitter handles. Often speakers will be talking about their topic du jour on their site or Twitter stream… maybe even posting their slides or blog posts talking about their topic. Nothing like paying attention to a speaker’s material before they have to get in front of a crowd of a few hundred folks – helps them fine tune and you get better insights.
4) Some speakers are at conferences at least partly to gain visibility in the tech ecosystem to get their book at the top of your reading list. OK, maybe I can’t hear you in person, but I can skim your book. You, speaker, went out of your way to be approachable at a conference. I, potential book purchaser and person interested in topic, value that putting yourself out there and may buy the book which you’ve basically set up your talk around.

For the record, I’m findable online for MIL-OSS (few OZONE Widget Framework GOSS talks, and one Ignite style session on “It’s the Community, Stupid”) and O’Reilly OSCON (2014: “Arduino + Furby Broken Build Notification – Oh, You’ll Want to Fix it Quick!”). I’ll add to it this year with another OSCON talk: “FURBY: ‘Go’ away!”. So watch my blog and Twitter feed for insights into the new talk as I mutter my way through evenings of code and Furby mumblings.

Doing some researching for my upcoming OSCON talk, ran across the following thread on golang-nuts, a Google Group dedicated to GoLang:

Silly question – why?. As in, why GoLang? A terrific thread for my OSCON talk. Note the originator of the thread: furby themselves. Spooky / scary / affirming / wow that’s amazing coincidence.

(For why that’s spooky / scary / affirming – check out my post describing my intended talk – Furby driven by Gobot, a robotics/IOT framework built upon GoLang.)

Thing just realized… a GitHub gist is its own repository. I’ve treated it as a place to drop notes, mostly, and only edited them via the Github interface. Tonight I tried cloning my gist, and discovered that worked nicely – I had my notes file handily on my local computer. Better, though, I realized I could add more items to my gist… Could set up separate files, all within the same gist context. Each shows up as a separate block containing content.

I next tried to setup a directory, just to see how it’d be conveyed in the interface. Added a directory, added a file within the directory, pushed it up. Went to the interface – nothing changed. Went back and looked: my branch now shows itself as 1 commit ahead of origin/master, and the push of the directory shows that it was rejected by the remote, with a pre-receive hook which indicates that ‘Gist does not support directories’.

Interestingly, gits do support branches. As I listened to my daughters sing some very odd version of Rudolph the Red-nosed Reindeer (who had a very advantageous nose…), I created a ‘weirdChildren’ branch. Git says it pushes up to origin, but the Gists don’t actually show me there’s a branch. I deleted my local branch, and then repulled from remote – got the changes that were unique to that branch.

Now, gists do offer a handy ’embed’ artifact, such as the following: . Whether the gist is secret or not, if that URL is given out, the contents of the Gist can be displayed. However, the URL doesn’t at least directly expose a way to browse the branches of a Gist. In GitHub.com, a branch would be exposed by using username/project/tree/branchName. E.g., colemanserious/gobot/tree/bmp180. That same /tree/branchName suffix doesn’t work on Gist, though: you end up on the GitHub’s well done 404 page. TLDR: if you use a branch for a Gist, you can futz with keeping versions hidden from all view, whether through gist searches or through those who’ve got a copy of your gist’s URL.

I recently got a request to submit a headshot photo to go along with my conference talk abstract. I’ve declined to respond, so far. I think I declined to respond the last time I gave a talk, as well. Were I a somewhat famous speaker, perhaps it might make sense to let folks say, oh yeah, I saw that person before – they were a good speaker. I suspect there are better ways to handle even that angle, like citing previous speaking engagements or linking to a video of the person’s previous talks. For the rest of us, it seems more like a way to let folks prejudge you before coming aboard. ‘Hmmm, that person looks friendly. Looks like me / doesn’t look me. Looks like they belong / doesn’t look like they belong.’

Conferences aren’t the only places that want pictures, though. LinkedIn strongly encourages a photo to increase your profile’s score. There’s a bit more logic to that – if someone’s scanning through a list of similar names, the picture lets you recognize the ‘Tina’ that you know, as opposed to the list of Tinas that you don’t.

Small company websites seem to take the headshot even a bit further. It’s a common meme to have a list of folks at the company, indicating their name (sometimes just first, sometimes full) and role within the company. I’ve seen several sites where the headshots are taken just a bit further – rolling over the picture shows another picture of the person, typically in some pose meant to highlight their fun-loving side interacting with the logo or brand image in some way. Perhaps this is meant to highlight their staff as well-rounded or engaging. Unless my role directly requires me to be an entertainer, whether I’m fun-loving or eye-appealing have nothing to do with how well I help the company satisfy its mission.

In my day job as a software engineer, I have used gravatars to help folks identify my work in a list of GitHub commit entries or other social network feeds. The one I use there is a cartoon Monopoly Man holding a pick axe… I thought it might help articulate my willingness to dig in and do the hard work. It happens to scale reasonably well to various sizes, always an advantage in having a consistent branding image. It also happens to look nothing like me. (I’m not male, elderly, or nearly that well-dressed.)

I’d like to encourage others to refrain from the headshot pressure. Or comment on this post and help me better understand why a picture is good supporting information for a conference speaker’s session description. For now, my OSCON bio will still be missing a head shot…

Last time, I talked about Powerball craziness. I confess, I bought tickets, both that Wednesday, and the following Saturday, when the payday was up above $1 bil. The enjoyment of dreaming was well worth the cost of the ticket. And if my ticket investment helped someone else’s dream, I’m OK with that, too.

Today we’re snow crazy. I live in Maryland, which is apparently just about ground zero for winter storm Jonas. The weather predictions are talking 20-30 inches. EVERYTHING’s already closed till Monday, even the local burger places. My kids were already going to be off Monday and Tuesday as part of the regular school schedule, and they got out two hours early today (again, scheduled). But they’re excited to hear that church is already called off for Sunday. They’re making plans for snowball fights, snow tunnels, and (thankfully for me) lots of shoveling. Work kicked me out at 2pm, and there’s pretty good odds we won’t be able to get in on Monday, just based on roads and parking lots being cleared.

There’re much worse things than being holed up at home with folks you love, having reasons to just hang out and have fun together….

When NPR writes about PowerBall, the country’s gone PowerBall crazy. Me included, though I think it’s a mild case. Given that the odds of winning are apparently 1 in 292 million, I’m not exactly banking our retirement and college planning on one of our few tickets hitting it big. In fact, as I’ve thought about the impact it’d make on our lives, I begin to wonder whether if I won, if I oughta avoid ever turning in the ticket.Continue reading

My husband tells folks I’m a fast reader. When our kids have been interested in reading new series or things we weren’t certain were appropriate, the rule has been that Mom reads it first, then the kids read it, and Dad gets it last if everyone else thinks it’s good. The kids seem to have inherited the fast-reading trait, so they’re not willing to wait on Dad (no slouch himself, just a more thorough guy who’ll reread sections as he goes along)…

This month, I got my hands on a series my girls have been reading, which they’d originally started on through books bought at the school book fair. They each got one of the last two books in the series for Christmas, bringing their total to 5. But I’d never read any of them. So, Monday Callie handed me the first one, called ‘Cinder‘. Tuesday afternoon I asked her for the second one, ‘Scarlet‘. This morning, I told her I was done Scarlet, and need ‘Cress‘. She groaned, and said, ‘You’re done already?’. It took us a while to track it down across the two girls’ rooms, and I spent a bit of this afternoon napping with a stomach bug, so it feels too late to start reading it this evening. Though I bet she asks me in the morning whether I’m already done…