Quantcast
Channel: A Portal to a Portal
Viewing all articles
Browse latest Browse all 1850

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

$
0
0
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 .....

Viewing all articles
Browse latest Browse all 1850

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>