Questions tagged [go]

Go is an open-source programming language, with a syntax loosely derived from C. It's statically typed, with limited dynamic typing capabilities; it also features automatic memory management, built-in concurrency primitives, variable-length arrays – called slices –, and a large standard library.

Filter by
Sorted by
Tagged with
0 votes
0 answers
15 views

Why does this ASM function call refrence a memory location just one byte ahead? [duplicate]

I am trying to compile Go for an operating system (without any standard go libraries whatsoever), and I wrote this go program: (ignore the fact that I'm using Go, yes, I know it will be painful) ...
Priff13's user avatar
  • 29
0 votes
0 answers
18 views

Unmarshal xml child nodes with a wild card in golang?

I'm learning how to use golang to unmarshal xml data. I almost got things working. I have this xml document: <athletes> <row> <name>John</name> <tournaments> ...
John's user avatar
  • 32.6k
0 votes
0 answers
23 views

Unable to unmarshal xml node name with golang

I want to learn how to unmarshal xml documents with golang. Let's say I have a file called athletes.xml with this content: <athletes> <boxer> <name>John</name> </...
John's user avatar
  • 32.6k
1 vote
1 answer
22 views

How can I check go.mod hash from sum.golang.org with Python?

I need to verify hashes for go.mod files provided by sum.golang.org. I need to use PYTHON. For example - https://sum.golang.org/lookup/github.com/gin-gonic/[email protected] for file https://proxy.golang.org/...
ElenaSh's user avatar
  • 11
-1 votes
1 answer
21 views

Abstracting away Go types without using interfaces

I'm forking and extending some 3rd-party code, to add an alternative implementation of some type. Emphasis on the fact that it's external code that I'm not the owner of, so I want to keep changes ...
j1elo's user avatar
  • 1,065
0 votes
0 answers
25 views

map with string and struct does not satisfy ~map[K]V

I have this struct type Package struct { name string isExplict bool size uint deps []string } and a map of type map[string]Package when I try to use the map in maps.DeleteFunc first ...
SpecTro's user avatar
  • 11
1 vote
0 answers
12 views

[GO][GIN] Ignoring createdAt field when create/update, but return to JSON response

I have a model (struct) on Golang type ExternalSystem struct { ID uint `gorm:"primary_key"` Name string `json:"name" binding:"required&...
Юрий's user avatar
-2 votes
0 answers
25 views

Finding maximum/biggest float value in Golang [closed]

I have problem with my code, specifically with float64 values. I calculate some weightings in my program, and need to find the highest value. So i did for loop, count the value and compare it with the ...
Damian Piotrowski's user avatar
1 vote
0 answers
9 views

How to add zapcore.NewMultiWriteSyncer in zap.Config using golang zap log project

I am working on a log package and hope to configure whether to use log rotation through switches. Previous code did not support log rotate // using zap.Config and cannot log rotate // Build ...
moluzhui's user avatar
  • 1,051
1 vote
1 answer
30 views

Accessing updated Request in wrapped middleware

I'm trying to write a logging middleware for a simple http server. I want to log the response status and bytes written. To accomplish this, I followed How do I get Response statusCode in golang ...
Soumil's user avatar
  • 111
1 vote
1 answer
52 views

Cannot import css because of its MIME type [duplicate]

I'm working on a simple golang web-app. Trying to add some css, but facing next problem: "Refused to apply style from 'http://localhost:8080/api/user/static/styles.css' because its MIME type ('...
tranq's user avatar
  • 11
0 votes
0 answers
44 views

Golang Extract ECDH Private Key

I know that ECDH private key is a superset of public key. The task is to extract private key ecdh. Here is the way how to generate PublicKey: import ( "crypto/ecdh" "...
27P's user avatar
  • 1,291
-4 votes
0 answers
39 views

Golang please help understanding the syntax [duplicate]

metadata is defined as: metadata map[string]interface{} please help me understand what is the following line doing: metadata["entity_version"].(string)
user2481909's user avatar
2 votes
1 answer
47 views

Delete s3 bucket object

I'm facing problems when deleting objects from an S3 bucket, my policies are these: { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "...
Guilherme Rodrigues's user avatar
1 vote
0 answers
30 views

How to spawn a detached process on Darwin?

How to spawn a detached process on macOS? When I try to do it using exec.Command and set proper SysProcAttr, I get: Error during starting process X: fork/exec X: operation not permitted I found that ...
user1666774's user avatar
-1 votes
0 answers
21 views

How to encode/decode slice of pointer while not exceeding the output length in golang? [closed]

I want to implement encoding/decoding to my go project: Encode function: take slice of string pointers and encode it to string Note: the output should not exceed 450 chars no matter how big the slice. ...
devi's user avatar
  • 40
0 votes
0 answers
24 views

x/tools/go/analysis: How to report RelatedInformation

I can only get the following results, Even if I set Related like this code pass.Report(analysis.Diagnostic{ Pos: n.Pos(), Message: "", Related: []analysis.RelatedInformation{{...
di hu's user avatar
  • 9
1 vote
0 answers
23 views

Hashicorp vault custom plugin unsupported path

I'm writing a custom plugin for Hashicorp vault in golang. I created a backend server to handle the plugin requests err := plugin.Serve(&plugin.ServeOpts{ BackendFactoryFunc: backend.Factory, ...
liorko's user avatar
  • 1,474
2 votes
1 answer
19 views

How to extend a cloned golang library using workspace approach

I'm writing a golang application and want to make use of an existing library. But that lib lacks some features, so I decided to fork the repo and add my new features to it. To be able to use the ...
mko's user avatar
  • 153
-2 votes
0 answers
17 views

Golang importer package: import package within module [closed]

I have this main.go file: package main import ( "fmt" "go/importer" "holdmybeer/db" "log" ) func main() { fmt.Println(db.DB) dbPkg, ...
Tobi696's user avatar
  • 452
0 votes
0 answers
47 views

Does the Azure CosmosDB SDK for Go support cross-partition queries?

I am using the Azure CosmosDB SDK for Go for my application, and I need to perform a cross-partition query in Cosmos DB. However, I'm not sure if the SDK supports this or how to correctly implement it....
Amir's user avatar
  • 31
-1 votes
0 answers
51 views

Go program does not handle Ctrl-C in cmd.exe on Windows 10

I am trying to create wireguard adapter using go. I am currently facing an issue with a Go program where the interrupt signal (Ctrl+C) is not being captured when I terminate the program before it ...
ks_'s user avatar
  • 25
2 votes
0 answers
45 views

How to Validate Trello Webhook Signatures in Golang Fiber?

I wrote the below code by Following: https://developer.atlassian.com/cloud/trello/guides/rest-api/webhooks/ Node.js Reference in Golang Fiber But Hash is not the same as Given Hash, Anyone kindly ...
javmah's user avatar
  • 129
1 vote
0 answers
31 views

Parsing Incorrect Values When Reading Excel File in Go Language

I'm working on a Go application where I need to parse dates from Excel files. The dates in Excel are in the format 27/06/1905, but when I use the Go excelize package to read, the date string value is ...
loc.dang's user avatar
  • 434
-2 votes
0 answers
43 views

Nil Pointer Exception in Go Gitlab Library [closed]

I'm working on a project that uses an external Go library (Gitlab's) and cannot for the life of me figure out what's causing a nil pointer exception. The exception is being caused by this handler. ...
Harrison Cramer's user avatar
0 votes
0 answers
20 views

mgo.v2 migrated to mongo-go-driver [closed]

I have a piece of golang code that implements mongo's addition, deletion, modification and query based on mgo. Now I need to modify its driver to mongo-go-driver. How can I switch its driver while ...
Elcn's user avatar
  • 9
2 votes
0 answers
34 views

How to Ensure Required Fields Presence and Validate HTTP Request with Echo Framework?

Is there a anyway to validate if a field is present in a http request with the echo framwork? Lets take this code for example: type ExampleStruct struct { Name string `json:"name"` ...
PopSmoke's user avatar
-4 votes
0 answers
35 views

golang "expected '(', found dealsyntax. Error [closed]

I'm learning along with a tutorial online and i'm getting an error in my code. The course has file assets when copy pasted I'm still getting the error. func deal(d deck, handSize int) (deck, deck) { ...
Karl Gauss's user avatar
0 votes
1 answer
38 views

Go program works with the single channel and runs into a deadlock with the introduction of a new channel

I am new to the go channels, I am trying to learn go channels by constructing a mock kernel and processes interaction through channels. The aim of this sample program is have multiple processes (2) ...
DDStackoverflow's user avatar
-2 votes
0 answers
50 views

Go with Postgres json/jsonb - probably not what you think [closed]

I'm building a simple API with Go gin to serve content from postgres db. Since the latter supports json data type I thought it would be a good idea to omit json Marshall/Unmarshall in Go and prepare a ...
jankes's user avatar
  • 31
2 votes
0 answers
57 views

Go issue when passing Windows path as CLI args

I am building a small CLI that takes as arguments two paths. It works fine on Linux and macOS but when using absolute paths on Windows, it breaks. This issue is illustred by the snippet bellow : // ...
foshan's user avatar
  • 21
2 votes
2 answers
54 views

Golang executed command with Run() is not returning

I am attempting to create a music streaming service using youtube-dl and ffmpeg. When a user sends a POST request with a video URL, my handler code works as shown below: router.POST("/submit&...
H.Okan's user avatar
  • 81
2 votes
2 answers
81 views

Accommodating heterogenous receivers in a Go constraint

Context This question is about defining the canonical, proper, or best-practice approach for defining type-constraints for types with a mix between pointer and non-pointer receivers. I define a few ...
Micrified's user avatar
  • 3,400
-1 votes
0 answers
40 views

golang dynamic simple read package.json main property with interface [duplicate]

I'm trying read simple tag 'version' of a node package.json file: { "name": "myproject", "version": "10.0.0", ... here just part of my code: type ...
DDave's user avatar
  • 1,444
1 vote
0 answers
26 views

Redirecting Standard Output to Current Console in Go Using CreateProcessWithTokenW

I'm working with Go and trying to launch a new CMD shell using CreateProcessWithTokenW. My goal is to redirect the standard output to the current console window so that I can run commands from the ...
OhGodWhy's user avatar
  • 175
2 votes
1 answer
53 views

Why is the cookie being set on the frontend domain?

I am running a golang server at localhost:8080 and nextjs server at localhost:3000 When you make a POST request to localhost:8080/login, it authenticates and sets a cookie. When I send a POST request ...
blank1729's user avatar
1 vote
1 answer
57 views

Mutexes do not seem to lock the Resources

I want that whenever there is switch on the file, My go routine reads from the new file. and for that I am using Mutexes to do so. But the output does not seem to be as expected. In f1.txt I have ...
Contour Free's user avatar
1 vote
2 answers
55 views

What makes the database pool concurrent-safe?

I recently used pgx library and it suggested to use connection pool over creating connection on demand during concurrency. The *pgx.Conn returned by pgx.Connect() represents a single connection and ...
Uday Reddy's user avatar
  • 1,393
-1 votes
0 answers
46 views

Are my @Schema openapi server annotations invalid? Openapi client generates inheritance for Java, Python, Angular, R, but not for C, C++, Go and Scala

I have some accounting model classes defined in Java: @Schema(description = "Comptes avec total, par habitant, moyenne strate, total réduction votée, réduction par habitant, réduction moyenne ...
Marc Le Bihan's user avatar
1 vote
0 answers
44 views

aiplatformb.PredictRequest.Instances expects type []*structpb.Value (GCP golang client library; aiplatform)

I am trying to hit my Vertex AI endpoint from a Golang web application (the web server/application is running on cloud run+build). The web application has a form that I'm landing into the Details ...
BBlank's user avatar
  • 76
0 votes
0 answers
24 views

Using docker RUN --mount=type=cache

I'm not fully understand docker's RUN --mount=type=cache mechanism, even having read the following articles, https://docs.docker.com/build/cache/ https://vsupalov.com/buildkit-cache-mount-dockerfile/ ...
xpt's user avatar
  • 21.1k
0 votes
0 answers
28 views

CTF server web task in go language

I can solve this task... Any suggestions? Most of users solved it package main import ( "fmt" "html/template" "log" "net/http" "os&...
1 vote
1 answer
25 views

How to Use the WSS Protocol on a Golang Web App hosted on Azure?

Background: I set up a web application using the Azure App Service. The server is written in Golang, and it serves a React client. The client makes a WebSocket connection to the server on load. My ...
Alex's user avatar
  • 33
0 votes
0 answers
32 views

Download the Latest Version of Golang on an AWS Instance [closed]

I am trying to download the latest version of go on my AWS instance, and want to know the best way to do it. So far I found either: $ sudo apt-get golang-go or $ wget https://go.dev/dl/go1.21.4....
dalewb's user avatar
  • 19
2 votes
1 answer
74 views

Implicit conversion of constant literal

In the below code: func main() { var a uint8 = 'x' fmt.Println(a) } 'x' is a constant literal (of untyped rune) Does variable declaration for a involve implicit conversion of type from ...
user1787812's user avatar
-2 votes
2 answers
92 views

What's the best way of emulating try/catch with golang

What's the best way of emulating a try/catch in golang . Consider the psuedo-code in java to execute a bunch of sql db.Attach(dbFile) try { db.Exec(sql1); db.Exec(sql2); db.Exec(sql3); } ...
Demeter P. Chen's user avatar
1 vote
2 answers
74 views

sync: negative WaitGroup counter

Who can tell me why the panic occurs. The background of this demo is to verify the behavior of slice cocurrent write, but when I run the demo, panic occurs occasionally (not always). So Why? The code: ...
Derrick's user avatar
  • 31
-3 votes
0 answers
21 views

app.routes undefined (type *application has no field or method routes) [duplicate]

I was trying to follow guide, however I'm facing a problem... When i try to run the program, getting message that app.routes undefined (type *application has no field or method routes). So the routes()...
Vladimir Gavrilenko's user avatar
0 votes
0 answers
52 views

Preconnect using http.Client in golang

So basically I need to make a multitude of HTTP Requests to an endpoint. I can use http.Client for this purpose. I know that making multiple HTTP Requests to the same endpoint using the http.Client ...
Antonio L.'s user avatar
0 votes
1 answer
37 views

How to have an instance object available to all tests?

I am writing component tests for an http service. I have a test runner class that houses some helpful structs and shared functions (mostly just "make an http call" and "compare json ...
Raeglyn's user avatar
  • 105

1
2 3 4 5
1435