type map[string]..... is not an expression

2,752 views
Skip to first unread message

sandi...@gmail.com

unread,
Nov 16, 2016, 9:05:54 AM11/16/16
to golang-nuts
package core

type MyContext struct {
CurClazz          string
CurLine           int
}

--------------------------------------------------------------------------------------------------------------
package main

import (
"fmt"
"pkg/core"
)


var us = map[string]core.MyContext 


--------------------------------------------------------------------------------

I am new to GoLang. Above code is giving build error "type map[string]core.MyContext is not an expression". Can someone please help?

pierre...@gmail.com

unread,
Nov 16, 2016, 9:16:16 AM11/16/16
to golang-nuts, sandi...@gmail.com
Your map is not initialized, do
either
  var us = make(map[string]core.MyContext)
or
  var us = map[string]core.MyContext{}

Reply all
Reply to author
Forward
0 new messages