Best Practices for Handling Many Optional Flags
Go Forum
by EugeneS
23h ago
I’m building a Go CLI application using Cobra and Viper libraries with numerous optional flags (10+). My primary goal is to execute actions only when their corresponding flags are specifically provided by the user. I’ve tried follwoing approach: Utilizing cmd.Flags().StringVar(flagVar, flagName, defaultValue, usage) and cmd.Flag(“flagName”).Changed Concerns: Repetition of flag names. Implicit binding between flagName and flagVariable. I’ve explored an option to use viper.BindPFlag and viper.IsSet, but it hasn’t given an answer to any of my concerns, and it feels like overkill for this relati ..read more
Visit website
Ignored issue (bug) that i noticed since update to go1.22
Go Forum
by kamal_shkeir
3d ago
Hi, My issue on github official repos was directly closed claiming that it is not a bug, that it is windows loader issue ??, i really didn’t understand the reason, so i would like to find some help here please, here is my issue: race tag: since go1.22 , running a program or running test with tag -race exit the program with status 0xc0000139 without any message for -v tag · Issue #66934 · golang/go · GitHub 1 post - 1 participant Read full topic ..read more
Visit website
Simple dependency import
Go Forum
by dancoe77
4d ago
Thanks for helping me in advance. Fairly new to programming. I have two dependencies and some code first is puppy: package puppy func Bark() string{ return "Woof!" } func Barks() string { return "Woof! Woof! Woof!" } github.com/dancoe77/008-puppy Next would be dog: import ( "strings" ) func WhenGrownUp(s string) string { return "When the puppy grows up it says: " + strings.ToUpper(s) } github.com/dancoe77/009-dog Finally there is the code that joins the two: package main import( "fmt" "github.com/dancoe77/008-puppy" "github.com/dancoe77/009-dog ..read more
Visit website
Using interfaces to select converted struct
Go Forum
by MattR
4d ago
I’m new to Go and learning by translating a C++ program I have into Go. The problem is that I have a graph with many types of nodes. In C++ this involves a base class and other classes built from that, along with coercing pointers to the base class into the correct node type. My understanding is that I can do this in Go with interfaces and conversions. What I have so far (simplified) is type Base struct{ id int up int } type Node struct{ Base left,right,down int } type Leaf struct{ Base val string } //and this is just a huge guess that doesn't work type NodeIf interface ..read more
Visit website
Noob Question : complex hello world example
Go Forum
by Didier
4d ago
Hello , Sorry for such a simple question : I am looking for a complex hello world example to illustrate a general module architecture and illustrate the maximum of situations : 4 packages , including packages at the same level and sub-packages 3 executables applications appli_1.exe appli_2.exe appli_3.exe The purpose of my question is to clearly understand the state of the art of import declaration in all the standard cases : Q1) SUB_BRANCH ACCESS : import for accessing from Hello_from_a a function in sub_package_a_aa or sub_package_a_bb Q2) EXTRA BRANCH ACCESS : import from sub_package_a_bb ..read more
Visit website
Is gomobile still viable for developing mobile SDK
Go Forum
by Bao_Ho
4d ago
We plan to use gomobile to build a shared SDK for our mobile apps and use it with binding, no UI with the go part, mainly for networking stack. However, look like there is little to no activities on gomobile github repository. Anyone knows if gomobile is still maintained? Is gomobile a viable solution, if not, what could be the alternative? Thanks 1 post - 1 participant Read full topic ..read more
Visit website
Is it a good idea to build the error messages by splitting the logic between the frontend and the backend?
Go Forum
by Willy
4d ago
In the frontend I have a form, let’s say like this (very simplified example): TYPE OF PRODUCT DATE RELEASE The detail is that this form can change labels for the inputs, then for another case (in another url) this same form would look like this: TYPE OF INFORMATION DATE RELEASE The inputs TYPE OF PRODUCT and TYPE OF INFORMATION have the same id in the frontend but different values and in the backend the validation and data handling is the same for both (even if they are from different url’s). So suppose the user entered the wrong data in form A and the backend would respond with a message ..read more
Visit website
Bobb - Small, Simple, Fast DB Tool
Go Forum
by JayPoss
5d ago
Bobb - Small, Simple, Fast DB Tool Built on bbolt (fork of bolt db). Goal is to hit the sweet spot between simplicity and functionality. Testing looks good, but I have not used it for any projects. Code on GitHub Most of the data tools we (developers) use are huge monsters. Bobb is the kind of tool that you can completely understand (except for the bolt part) and use all of its features. If you try it out and have any comments, I would be thankful for the feedback. Jay 1 post - 1 participant Read full topic ..read more
Visit website
Sending structure over tcp link
Go Forum
by RonZil
5d ago
Hi! Want to find out what is the best way in terms of efficient and simplicity of implementation to transfer message from a specific type? The problem that i want to solve is that I want every message to be from the form of {title, body, timeStamp} but until now I used buffers and sent only byte messages. The efficiency is important to me in my use case. I heard about protobuf. is it the best solution for me? And a second question on that topic is, if I’m developing on a windows machine but working with Ubuntu terminals using WSL, should I install the protoc (the protobuf compiler) in a window ..read more
Visit website
Call methods from goroutine
Go Forum
by MikeSolem
5d ago
I have an object A with some methods: Get1(), Get2(), Get3()… That object is being used by a goroutine. Another goroutine wants to call those Get methods. How should this be done safely? I can think of several ways of handling this. A mutex could be added, but the guidance seems to be to use channels when possible. My question is: what is the most idiomatic way of doing this safely in Go? Thanks, Mike 1 post - 1 participant Read full topic ..read more
Visit website

Follow Go Forum on FeedSpot

Continue with Google
Continue with Apple
OR