Saturday, 20 April 2019

More tales from a GoLang newbie ... expected 'IDENT', found 'break'

I'm adopting, and loving, Microsoft Visual Studio Code ( VSCode ) for all my GoLang needs, but was somewhat confused by this: -

expected 'IDENT', found 'break'


This is my code: -

package break

import (
"fmt"
)

func BreakGoTest() {
snafu := []interface{}{"First", "Second", "Third"}
fmt.Println(snafu...)
}

Can you see what I did wrong ?

Yep, I've named my package .... break .... which is a reserved word.

Once I changed my package name: -

package breaker

import (
"fmt"
)

// BreakGoTest - This function does stuff
func BreakGoTest() {
snafu := []interface{}{"First", "Second", "Third"}
fmt.Println(snafu...)
}

all is well.

For the record, this code is merely to allow me to test go fmt .....

No comments:

Note to self - use kubectl to query images in a pod or deployment

In both cases, we use JSON ... For a deployment, we can do this: - kubectl get deployment foobar --namespace snafu --output jsonpath="{...