-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version
)?
go version go1.8.1 windows/amd64
What operating system and processor architecture are you using (go env
)?
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\user\go
set GORACE=
set GOROOT=c:\tools\go
set GOTOOLDIR=c:\tools\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set PKG_CONFIG=pkg-config
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
What did you do?
Trying to compile this piece of code:
// func (r *Room) wrapRoomEventHandler(callback EventCallback) EventCallback
eventHandler := world.getRoom("room").wrapRoomEventHandler(
func(player *Player, context interface{}, args ...string) (result interface{}) {
if args[0] == "backpack" && player.inventory == nil {
player.inventory = &Inventory{}
return "wearing the backpack"
}
return context
} // here it wants me a comma, but why?
)
What did you expect to see?
This code to be compiled.
What did you see instead?
.\main.go:71: syntax error: unexpected semicolon or newline, expecting comma or )
Actually, it forces me to put a comma after the last closing curly brace. And it is totally understandable for any kind of lists/arrays/slices/etc, but why does it force me to add a comma after the function function argument? (which is the last and the only one)
P.S. Sorry, I'm totally new to go, and probably this is a well-known feature of the language, that I'm not aware of.