Top "Go" questions

Go is an open-source programming language.

Optional Parameters in Go?

Can Go have optional parameters? Or can I just define two functions with the same name and a different number …

go overloading
What is the best way to test for an empty string in Go?

Which method is best (more idomatic) for testing non-empty strings (in Go)? if len(mystring) > 0 { } Or: if mystring != "" { } Or …

string go is-empty
How to check if a file exists in Go?

Go's standard library does not have a function solely intended to check if a file exists or not (like Python's …

file go standard-library
Does Go have "if x in" construct similar to Python?

Without iterating over the entire array, how can I check if x in array using Go? Does the language have …

if-statement go
Has been blocked by CORS policy: Response to preflight request doesn’t pass access control check

I have created trip server. It works fine and we are able to make POST request by Insomnia but when …

go axios
Go build: "Cannot find package" (even though GOPATH is set)

Even though I have GOPATH properly set, I still can't get "go build" or "go run" to find my own …

build go package
How to import local packages without gopath

I've used GOPATH but for this current issue I'm facing it does not help. I want to be able to …

go package
Format a Go string without printing?

Is there a simple way to format a string in Go without printing the string? I can do: bar := "bar" …

string go formatting string-formatting
Getting a slice of keys from a map

Is there any simpler/nicer way of getting a slice of keys from a map in Go? Currently I am …

go
How to read/write from/to file using Go?

I've been trying to learn Go on my own, but I've been stumped on trying read from and write to …

file go