go Questions
3
I've been trying to use the Heap package in Go and I am not sure on how to initialize it.
package main
import "container/heap"
type PriorityMessage struct {
Priority int
Message string
}
func...
Koontz asked 27/11, 2019 at 21:51
2
I have been using Go Validator.v2 for field validations and it works elegantly for my non-struct typed fields. However, when it comes to handling struct-based fields (within the original struct), t...
Schreiber asked 20/10, 2020 at 9:2
4
Solved
have error with nats-server -js
when i want publish msg with golang in nats-server -js, i have error like this: nats: no response from stream
i want publish video to nats-server -js
this is my pub ...
Potluck asked 8/5, 2021 at 23:5
3
Solved
I am getting this error while running make test on a Golang project:
signal: killed
FAIL <package name>
make: *** [test] Error 1
The same code was running perfectly fine until yesterday.
N...
3
For my project I am trying to get all the dependencies and sub dependencies of my project. I need to specific version of each of these dependencies. Not only do I need the dependencies of my projec...
Kicksorter asked 11/9, 2019 at 22:22
4
Solved
we are trying to debug Go code and getting this error:
could not launch process: decoding dwarf section info at offset 0x0: too short
our settings:
WITSC02X6385JGH:orderer sjain68$ uname -a
Dar...
4
Solved
I am having a hard time learning how to loop through a string in Go to do some stuff (specifically, to separate words than contain vowels).
I wrote this code snippet: https://play.golang.org/p/zgDt...
Exeunt asked 24/8, 2016 at 9:5
4
Solved
Imagine I have the following struct:
type MyGeneric[T string | int] struct {
}
I want to check whether the generic used to instantiate that struct was a string or a int when creating a new MyGener...
Leukoderma asked 27/9, 2022 at 8:45
3
Solved
I'm trying to execute go build -buildmode=shared -linkshared test but I'm getting the error:
go 1.10: cannot implicitly include runtime/cgo in a shared library
I have only one file in that packa...
Bohner asked 4/9, 2019 at 18:13
5
Solved
Is there a way to flatten a dictionary with helm? I want to provide environment variables to the application from the chart by flattening a YAML config located in values.yaml. The config can look l...
Lashonlashond asked 17/4, 2020 at 21:19
4
Solved
I have model like this in
model.go
type yourTableName struct {
Name string `gorm:"type:varchar(50)" json:"name"`
Email string `gorm:"type:varchar(50)" json:"e...
Earnest asked 24/12, 2020 at 4:51
5
Solved
I have a log file, and I need to parse each record in it using golang.
Each record begin with "#", and a record can span one or more lines :
# Line1
# Line2
Continued line2
Continued line2
# line3...
Synonymize asked 11/10, 2015 at 18:34
2
I try go1.16
import "embed"
I get
> golangci-lint run ./...
> Can't run linter goanalysis_metalinter: bodyclose: failed prerequisites ... could not import embed
how skip file/pack...
3
Good day! I try to migrate from glide to go modules (private gitlab repos)
and checkout code via ssh
I have a simple project with an import from private gitlab repo.
go.mod looks like:
module my...
Daron asked 25/12, 2019 at 12:47
3
Solved
I created a logger with kubebuilder, it is based on zap logger:
import (
"flag"
"github.com/gin-gonic/gin"
"net/http"
"os"
"go.uber.org/zap/zapcore...
3
Solved
I am using a third party library in GoLang that has previously had import paths in different case. Initially a letter was lower case then the author changed it to uppercase.
Some plugin authors up...
Chak asked 25/4, 2017 at 18:59
1
Given a []int, e.g: is := []int{2, 4, 1, 3}
Can sort via:
sort.Sort(), e.g:
sort.Sort(sort.IntSlice(is))
slices.Sort(), e,g:
slices.Sort(is)
I know slices.Sort() is experience, from "gol...
4
Solved
I am following this guide.
***@pop-os:~/go/src/foo$ cobra init --pkg-name foo
Command 'cobra' not found, but can be installed with:
sudo apt install cobra
My setup:
I have go 1.16 installed
$ go v...
4
Solved
Starting from Go v1.6 cgo changed the rules of passing pointers to the C code golang/go#12416.
The example of invoking a dynamic Go callback from C code from the wiki doesn't work anymore.
package...
2
I am writing a golang command line program that accepts user input. This input string has to be converted to UTF-8 and sent to another server for processing. On Linux, the terminal encoding is almo...
Scrimp asked 6/10, 2016 at 1:23
3
Solved
I have an array of structs (struct detailed at bottom)
I want to find all the structs that match certain values for, example, leg and site.
So if leg=101 and site=1024A give back all the structs ...
Endotoxin asked 11/10, 2013 at 16:17
3
Solved
Go 1.16 is out and I want to use the new embed features. I can get it to work if everything is in the main package. But it's not clear how to handle accessing resources from subfolders/packages. Tr...
2
In my database I have a users table, joined via a many-to-many table to schools. A school has many jobs. I'm trying to return all the schools and their jobs for a specific user. This is my code so ...
5
Solved
Is it possible to differentiate between false and an unset boolean value in go?
For instance, if I had this code
type Test struct {
Set bool
Unset bool
}
test := Test{ Set: false }
Is there...
4
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 readStuff(scanner *bufio.Scanner) {
for sc...
Seligman asked 20/12, 2014 at 4:24
1 Next >
© 2022 - 2024 — McMap. All rights reserved.