74,408 questions
-3
votes
0
answers
66
views
Conn.Write not sending data until I terminate program [closed]
I am writing a simple snippet of code to help me better understand HTTP requests and TCP sockets using the net package. but I have discovered that the call I make to Conn.Write isn't sending the data ...
2
votes
1
answer
111
views
How can I add an ASCII art before this system information?
I am trying to build a neofetch/fastfetch like program from scratch, and I want to know how I can add an ASCII art to the left of my system information
package main
import (
"fmt"
&...
1
vote
1
answer
39
views
Adding files to image built with ko build
I have a go application that is being containerized via ko build. This is the ko build command im using to build my image:
ko build ./cmd/webserver \
--platform=linux/amd64,linux/arm64,linux/arm/...
5
votes
1
answer
96
views
Linking Zig and Go for windows API
I'm trying to link a zig static library with golang. here is my build.zig
const std = @import("std");
pub fn build(b: *std.Build) void {
const windows = b.option(bool, "windows&...
-3
votes
1
answer
59
views
How to sync cli command with golang
I recently tried to write my first small app. At the end of this app I try to load a docker image from a local file. The code itself runs on windows 11 and fully works. The only issue is that go ...
0
votes
1
answer
58
views
How to allow admin to cancel a long-running MQTT device activation in Go when using unbuffered channels? [closed]
I’m building a Go backend to control IoT motors via MQTT. Each device activation is handled asynchronously by a goroutine. Here’s the simplified flow:
A client POSTs /activate-device with device_id ...
0
votes
1
answer
53
views
Golang crypto ssh package: attempted methods [none]
I am trying to ssh into Arista EOS Switch by using golang package: golang.org/x/crypto/ssh, the idea is to ssh into switch, execute some commands and get output.
here is my code:
func ExecuteCommands(...
2
votes
0
answers
108
views
Install additional Go versions into folder other than ~/sdk
Wanting to try out Go 1.25, I followed the instructions on the Go website on installing multiple versions.
Everything worked beautifully, except that it created a new folder named sdk in my home ...
4
votes
0
answers
44
views
How to check if an optional struct field is set using 'x-kubernetes-validations' and CEL expressions?
I have the following go struct that is part of a bigger struct which is converted into a Kubernetes CustomResourceDefinition:
type RoleRef struct {
// Name is the name of the role or cluster role ...
0
votes
0
answers
53
views
vscode can't run program in playground ... says it can't find module on github
I have a helloWorld program with a package
helloWorld
|----- morestrings
|------- reverse.go
|------- reverse_test.go
|--- hello.go
|--- go.mod
...
2
votes
1
answer
131
views
Why does gofmt replace two single quotes with a single double quote in my Go comment in some cases?
I'm writing a Kubernetes controller in Go using VS Code and have the problem that, on saving the file, a double single quote ('') is replaced by some kind of double quote (”). The double quote is ...
2
votes
1
answer
40
views
RPC Call cannot find relevant method in Go in Raft Consensus
I am working on implementing Raft Consensus in Go, and there is an RPC handler that is not registering for some reason. I have cross checked my method signature and it matches the Go format for RPC ...
1
vote
2
answers
174
views
How to make a mock for time.Now() in Go unit test
I have been reading various ways of making a mock for time.Now() and try to make the unit test.
Let's say we have a Customer struct.
type Customer struct {
Name string
CreatedDate sql....
-2
votes
1
answer
136
views
Does having many Go packages impact runtime performance? [closed]
I'm working on a Go project and experimenting with organizing code into packages. Specifically, I’m wondering:
If I create around 1 000 packages in my Go project (one package per file), does that ...
1
vote
1
answer
39
views
Why does my ERD show mandatory participation for Device when it should be optional? (GORM + SQL)
I’m modelling a relationship between Device and DeviceSession in GORM/SQL.
Business rules:
Each DeviceSession must have exactly one Device (mandatory from
session side)
A Device can have zero or ...