Category "go"

_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

How to use log4go with configuration file?

I have been trying to use log4go in golang. But I could not find a proper example where log4go configuration properties were used like rotation,maxSize etc to c

Unable to build protobuf to go endpoint

using protobuf version 2.6.1 ( which i installed via homebrew) I am trying to run $ protoc --go_out=../cloud/ *.proto I keep receiving this error. $ p

check if given path is a subdirectory of another in golang

Say we have two paths: c:\foo\bar\baz and c:\foo\bar Is there any package/method that will help me determine if one is a subdirectory of another? I am looking

How do I reverse a slice in go?

How do I reverse an arbitrary slice ([]interface{}) in Go? I'd rather not have to write Less and Swap to use sort.Reverse. Is there a simple, builtin way to do

Use google cloud aiplatform with golang

I have a vertex AI modele deployed on an endpoint and want to do some prediction from my app in golang. To do this I create code inspired by this exemple : http

Is it possible to mock a function imported from a package in golang?

I have the following method to test, which uses a function imported from a package. import x.y.z func abc() { ... v := z.SomeFunc() ... } Is it

Reading Stdout from a subprocess

I am attempting to spawn a subprocess from Golang. The goal is to read and process the input line-by-line. Here is what I am trying to get working: func readSt

How to format current time into YYYY-MM-DDTHH:MM:SSZ

Never tried Go before and currently doing a small project. One of the task is to get current system time and represent it in YYYY-MM-DDT00:00:00Z format. I beli

Correct way of getting Client's IP Addresses from http.Request

What's the correct way to get all client's IP Addresses from http.Request? In PHP there are a lot of variables that I should check. Is it the same on Go? One

missing go.sum entry for module providing package <package_name>

Using the buffalo framework, after bootstraping it via buffalo new <project_name> I am trying to run buffalo dev Expecting to see: project running on por