go Questions
2
I've run into a problem benchmarking my Go programs, and it looks to me like a Go bug. Please help me understand why it's not.
In a nutshell: benchmarking hangs when I call b.StopTimer() even if I...
Gauger asked 3/6, 2016 at 17:24
3
Solved
Trying to import a private repo as package in golang. Did:
git config --global [email protected]:.insteadOf https://github.com/
So in theory all references to https are replaced by the ssh ...
2
tl;dr
I'm trying to understand the difference of running a program directly via double clicking the executable vs running it through a terminal or programatically via CreateProcess in windows 10.
...
Gleanings asked 30/3, 2019 at 17:36
2
Solved
marshalling and unmarshalling are not working properly with xml namespace prefix
go version 1.9.2
See below code:
package main
import (
"fmt"
"encoding/xml")
type DeviceId struct {
XMLN...
Liddle asked 4/2, 2018 at 15:16
2
Solved
I need a function to atomically add float32 values in Go.
This is what came up with based on some C code I found:
package atomic
import (
"sync/atomic"
"unsafe"
"math"
)
func AddFloat32(addr ...
Leadership asked 15/12, 2014 at 20:14
5
Solved
I'm trying to test a method that uses net/http to make requests. Specifically what I'm trying to achieve is to inject a mock http.Client that responds with a certain JSON body
type clientMock stru...
Arieariel asked 22/11, 2017 at 13:43
2
I'm trying to profile an application written in go which apparently uses about 256 virtual memory (checked using ps aux). I'm trying to use pprof package and see what functions allocate/consume mos...
Minaret asked 18/8, 2015 at 16:42
6
Solved
How do I use bufio.ScanWords and bufio.ScanLines functions to count words and lines?
I tried:
fmt.Println(bufio.ScanWords([]byte("Good day everyone"), false))
Prints:
5 [103 111 111 100] <n...
Powerless asked 17/4, 2017 at 10:57
4
Solved
I'm trying to migrate from aws-sdk-go to aws-sdk-go-v2. But, I am using localstack locally to mimic some aws services such as sqs and s3. I'm not sure how to configure the new sdk to use the locals...
Korman asked 8/2, 2021 at 15:37
5
Solved
In a web service implemented in Go, I want to be able to restrict fields returned in a JSON response based on a user's role.
For example I may have a currently logged in user who has a role of gue...
4
Solved
I run go test in my pkg directory and I get the test results printed to the console as they run, but it would be ideal if I could get them printed to a txt file or even a html file, is it possible ...
Morganstein asked 19/3, 2015 at 17:5
2
Solved
I'm trying to read version control information from my Go binaries, but the build info doesn't seem to contain any VCS info.
From the Go 1.18 release notes:
The go command now embeds version contr...
Afghani asked 28/3, 2022 at 4:19
2
Solved
I'm working on a piece of code that returns uint data type. I need to convert uint datatype into string for further processing.
I've already tried strconv package and none of the functions accept ...
Shadshadberry asked 24/7, 2019 at 16:55
1
Imagine you want to get kind/struct called KubeadmControlPlane from the kubernetes API server.
This means you need to import the related struct into your code.
A matching import statement for Kubea...
Kentigera asked 26/5, 2023 at 6:53
4
Want "30 of month" but get "30"
package main
import "fmt"
func main() {
var s string
fmt.Scanln(&s)
fmt.Println(s)
return
}
$ go run test.go
31 of month
31
Scanln is similar to Scan...
4
Is it possible to pass a string of go code into go run instead of go run /some/path/script.go? I tried:
echo "some awesome go code here" | go run
But does not work. Thanks.
Terranceterrane asked 26/10, 2013 at 0:16
2
Solved
I've been attempting to take a swing at concurrency in Golang by refactoring one of my command-line utilities over the past few days, but I'm stuck.
Here's the original code (master branch).
Here...
Nickels asked 25/5, 2016 at 14:12
2
Solved
How can I get an exclusive read access to a file in go? I have tried documentations from docs but I am still able to open the file in notepad and edit it. I want to deny any other process to have a...
Nelrsa asked 25/10, 2018 at 9:55
5
Solved
How can I hook up my local minIO storage with aws-sdk-go-v2? I can find clear documentation of how to do that in the previous version of go SDK but not with V2. I read through the version 2 source ...
Occupancy asked 17/5, 2021 at 19:6
6
Solved
I'm using Echo to build a minimalist server in Golang.
In, Echo one can bind an incoming JSON request payload to a struct internally and access the payload.
However I have a scenario wherein I k...
5
Solved
I am from a C background and passing an array in C style causes an error.
package main
import "fmt"
func f(a *int){
fmt.Println(a[1])
}
func main(){
var a [100]int
a[1]=100
f(a)
}
Error:: ...
3
Solved
From the documentation it states that
For server requests the Request Body is always non-nil but will return EOF immediately when no body is present.
For ContentLength, the documentation stat...
2
Solved
We need to use a custom unmarshaler for a struct nested in multiple other structs which don't require a custom unmarshaler. We have lots of structs similar to B struct defined below (similar as in ...
Disney asked 12/9, 2018 at 11:24
2
When I run single test with go test -run TestNewProbeServiceIsSingleton it passes as expected.
Problem occurs whenever I am trying to test the whole package/app using go test ./... from my project'...
Marta asked 2/8, 2020 at 11:34
5
Solved
Essentially, I am trying to run a query on a MySQL database, get the data made converted into JSON and sent back to the client. I have tried several methods and all of the "easy" ones result in sen...
Piotrowski asked 13/3, 2017 at 22:19
© 2022 - 2024 — McMap. All rights reserved.