Category "go"

go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1 /usr/bin/ld: cannot find -lgdal

I am trying to run go build on my sources. go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1 /usr/bin/ld: cannot find -lgdal collect2: error: ld

How to set TLS cipher for Go server?

I'm currently using the following listen and serve command to run a secure websocket/file server: http.ListenAndServeTLS(":443", "site.crt","site.key", router)

casting overlapping structs in golang

I'm new to golang and trying to figure out the correct way of casting a block of bytes to the correct struct. All structs start with two bytes that dictate the

When debugging, GoLand can not evaluate a function on M1

When debugging, use the Evaluate expression and try to evaluate a function. The result is shown as: "backend does not support function calls". Why? MacBook Pro

How do I do a literal *int64 in Go?

I have a struct type with a *int64 field. type SomeType struct { SomeField *int64 } At some point in my code, I want to declare a literal of this (say, w

How do you deal with wall-clock times without date in Go?

I'd like to know if there is any existing package to deal with datetimes without date in Golang. The problem is as follows. Imagine I want to store information

How can I install a package with go get?

I want to install packages from github to my $GOPATH, I have tried this: go get github.com:capotej/groupcache-db-experiment.git the repository is here.

Can I change default compiler used by cgo?

I am trying to execute cgo code under ubuntu 14.04, it seems like cgo assume CC/CXX to be gcc/g++. And I need to explicitly specify CC/CXX in order to use, say,

Golang: what is atomic read used for?

Here we have a go case provided by Go by Example, to explain the atomic package. https://gobyexample.com/atomic-counters package main import "fmt" import "ti

gRPC server blocked on SendMsg

We're having an issue where our gRPC streaming server is blocked on SendMsg with the following stack trace: google.golang.org/grpc/internal/transport.(*writeQuo

_cgo_export.c:3:10: fatal error: 'stdlib.h' file not found while running go test in VS Code after upgrading to mac OS Big Sur

I'm trying to learn select statements in go from learn go with tests. Just before this I upgraded macOS to Big Sur version 11.4. Now I'm trying to run the follo

Is there a Golang terminal shell? Is it possible for a compiled language? [duplicate]

Recently I'm interested in Golang. When I was learning Python I kicked off a terminal shell and just practised throwing it different data, f

go build can't find a revision

I developed a repo on computer A and created a go.mod/go.sum that I checked in. I pull that repo with the go.mod/go.sum files on computer B, but when I try to

How to shuffle strings in arrays in golang?

So I created a program to help me decide which game to play. Before I start my problem let me show you my code: package main import ( "fmt" "strconv"

How can I sleep with responsive context cancelation?

In Go, I want to time.Sleep for some time (e.g. waiting between retries), but want to return quickly if the context gets canceled (not just from a deadline, but

Why does go get fail with "invalid version: unknown revision"?

I published an update to a Go module, bumping the version to v1.1.0. I created a tag named v1.1.0 and pushed the tag to GitHub. https://github.com/depp/bytesize

How to replace all html tag with empty string in golang

I'm trying to replace all html tag such as <div> </div> ... on empty string ( " " ) in golang with regex pattern ^[^.\/]*$/g to match all close tag.

Return map like 'ok' in Golang on normal functions

In Go, the following works (note one use of the map has one return, the other has two returns) package main import "fmt" var someMap = map[string]string { "s

[]byte(string) vs []byte(*string)

I'm curious as why Go doesn't provide a []byte(*string) method. From a performance perspective, wouldn't []byte(string) make a copy of the input argument and ad

Multiple values in single-value context

Due to error handling in Go, I often end up with multiple values functions. So far, the way I have managed this has been very messy and I am looking for best pr