Questions tagged [go]

Go is an open source programming language initially developed at Google. It is statically-typed, with a syntax loosely derived from C, adding automatic memory management, type safety, some dynamic typing capabilities, additional built-in types such as variable-length arrays and key-value maps, and a large standard library.

0
votes
0answers
2 views

How to test Go code with filepaths defined as constants

I'm writing tests for a project of mine, which involves fixed filepaths and base URLs. To me, the most logic way to define them is by means of public/private constants in a relevant module, but that ...
0
votes
0answers
7 views

Selecting related fields with GORM

I'm new to Golang coming from a python background so trying to understand the new and different concepts. I'm trying to create related fields and then select them from the database. models type ...
-1
votes
0answers
10 views

why go cross compile have some different behavior within mac to linux platform?

i have a go program compile in Mac, the program is alright, but when i try to cross compile to linux, use command:"env GOOS=linux GOARCH=386 go build", when i deploy it on linux, it can run, but have ...
0
votes
0answers
13 views

How to get DOM HTML in Go

I'm writing a parser HTML in Go. I need to get HTML and pass it to another function. I did it so: Can`t pass "doc" to another function receivedURL, err := http.Get("http://lavillitacafe.com/") ...
0
votes
2answers
15 views

go get installation from a local fork

I am trying to install a go package from a local directory (basically I checked out and existing package and applied a pending pull request). $ # Both commands give a similar output $ go get -u file:/...
0
votes
0answers
5 views

callgraph: unclear calls in the output of callgraph tool

I came across some unclear result when used callgraph to analyze go-ethereum project. Could you give me a clue to find an explanation, please? I used these commands to generate reports: 1) rta ...
0
votes
0answers
21 views

Golang: how to generate a net/http timeout Error to perform unit test

I got a piece of code like below: if timeoutErr, ok := err.(net.Error); ok && timeoutErr.Timeout() { // Some code that need to test } How could I generate a error that can match the ...
-1
votes
0answers
10 views

How should bufio.SplitFunc handle empty data when atEOF

I am implementing my own custom bufio.SplitFunc and I'm getting panic: bufio.Scan: too many empty tokens without progressing [recovered] panic: bufio.Scan: too many empty tokens without ...
-1
votes
0answers
17 views

Lines of code per binary overtime in Golang

Use case: There are multiple micro-services code present in a single repository in Github. Each micro-service is a separate binary. How to calculate lines of code per binary? How to calculate lines ...
0
votes
2answers
17 views

Channel receive from just a Println in go routine throws deadlock exception

I have some code where i am trying to print the content of a channel in a goroutine using fmt.Println. Here is the simplified version of code. package main import "fmt" import "time" func main() { ...
2
votes
1answer
20 views

golang program memory keep growing but has just a little inuse_space

I have a golang program running some routines periodically. Its memory (RSS in top result) keep growing on some servers but on some server it doesn’t. What's weird is that the pprof result of the RSS-...
0
votes
0answers
36 views

How to call function F1() before a F2() in golang

I have a function F2() already in production. F2() is getting called from many other places. I don't want to touch F2() or don't want to touch all the places from where F2 is getting called. How do I ...
1
vote
2answers
30 views

How can I create a TLS connection without certificates in golang?

From the source: // Listen creates a TLS listener accepting connections on the // given network address using net.Listen. // The configuration config must be non-nil and must include // at least one ...
0
votes
1answer
19 views

Run a benchmark in parallel, i.e. simulate simultaneous requests

When testing a database procedure invoked from an API, when it runs sequentially, it seems to run consistently within ~3s. However we've noticed that when several requests come in at the same time, ...
0
votes
0answers
29 views

database schema design for event organizer

I have recently embarked myself to learn a project which was given to me by my former co-worker where they gave me a technical challenge to design an golang app, I am still learning the language and ...
4
votes
1answer
64 views

How to download Protocol Buffers v3 from this site?

I'm following this tutorial to install Protocol Buffers v3: https://grpc.io/docs/quickstart/go.html#install-grpc It says "The simplest way to do this is to download pre-compiled binaries for your ...
1
vote
1answer
44 views

What causes “Pattern matched no module dependencies” when using go mod download?

When running go mod download the warning (warning: pattern "all" matched no module dependencies) is shown and none of the modules in my go.mod file are download to the local cache. I've spent the ...
1
vote
1answer
41 views

Why Go is not being detected?

I'm trying to install Go, gRPC and Protobuf but I cant even install Go in the first place. I followed steps mentioned in this site: https://tecadmin.net/install-go-on-centos/ My bash_profile file ...
0
votes
0answers
14 views

Problem serving static files on subdomain

I'm having Problems setting up my static file serving for a Subdomain using the gorilla/mux package. I have a mux router set up that has some routes for other projects and now I want to serve static ...
0
votes
2answers
29 views

Subtraction of large numbers golang

I did not think that I would have to write about it, but nowhere can I find at least an example of subtracting large numbers So I have two numbers and I want to subtract them, the library says that ...
2
votes
0answers
43 views

Does golang atomic.Load have a acquire semantics?

Given a c++ code snip: int a = 0; atomic<int> b{0}; Thread 1 a = 1; b.store(1,memory_order_release); Thread 2 while(!b.load(memory_order_acquire)); assert(a==1); We ...
2
votes
1answer
15 views

standard_init_linux.go:190: exec user process caused “exec format error” when running Go binary

I am attempting to create a container with my Go binary in for use as a database migrator. If I run the binary it works perfectly, however, I am struggling to put it into a container and run it in my ...
1
vote
1answer
18 views

Include Go dependencies in Docker container using mono repo

I have a mono repo with the structure. mono-repo - serviceA - main.go - Dockerfile -serviceB - main.go - Dockerfile go.mod go.sum The Dockerfile in serviceA contains the following code. FROM ...
2
votes
1answer
22 views

How to use OS or Arch specific code in Go

Apparently, syscall.Dup2 does not exist on ARM systems, and syscall.Dup3 does not exisxt on darwin (OSX). This means I could use syscall.Dup3 on ARM, and syscall.Dup2 on other platforms, for example. ...
0
votes
1answer
25 views

Acquiring a lock over a memory address instead of variable in golang

I have an interface called Setter. Struct called SetterImpl implements this interface and has 2 setters, all of which set 2 interfaces. type Setter interface { A() *AInterface B() *BInterface ...
-1
votes
0answers
22 views

Error runing golang built binary : panic: zmq4 was installed with ZeroMQ version 4.2.0, but the application links with version 4.2.1

I'm trying to run an application written in Go by another team. When I run it, I get this error "panic: zmq4 was installed with ZeroMQ version 4.2.0, but the application links with version 4.2.1". ...
3
votes
1answer
36 views

How can I use Go modules to pull a dependency by commit hash or branch?

I'm trying to upgrade my project to use Go modules for dependency management. I recognize this a new/experimental feature. I'm getting an error: cannot find module providing package. My go.mod ...
0
votes
1answer
24 views

How can I keep golang's golang version and my Dockerfile in sync?

I'm new to goland, trying to pick it up on my first project. I'm noticing in goland that it doesn't show the same golang SDK that is pulled in through the container. Here's my Dockerfile: FROM ...
0
votes
0answers
30 views

UI and API Questions for a long running process

I have a web app that grabs an Apache 'access.conf' file from internal GitHub, and then sends it via an HTTPS type of authenticated request to our server farm in a temporary dir. When the file gets ...
3
votes
1answer
84 views

What is purpose of methods with blank names?

I have just started studying golang and during reading specification I found some question that I can't resolve by myself. In the section about method declaration the language specification says "If ...
1
vote
1answer
35 views

Golang: reflect.DeepEqual returns unexpected false

I have the following code and code test below and for some reason the deepEqual is returning a false and failing the test. Now from reading the doco on this I would expect this to pass with a true for ...
-1
votes
0answers
33 views

How do I connect to running Go web servers on my network from different devices? [on hold]

I cannot for the life of me figure out how I can connect to my Go running on a Linux PC from my Windows PC using the address 192.168..:8080. This is works the other way around with the Windows PC is ...
0
votes
0answers
32 views

How to create a SOAP webservice in GOLANG

I am newbie in GO and I am looking to create a new SOAP web-service in GO. I have seen examples of how to consume a soap service in GO i.e. writing clients for SOAP services and generating code using ....
3
votes
1answer
38 views

How to fix this gRPC installation problem?

Im following these steps to install gRPC on my freshly launched AWS EC2 Instance: https://jitpaul.blog/2018/04/18/grpc-on-aws/ When I try to execute this line: sudo yum install libgflags-dev ...
1
vote
1answer
19 views

How to run golang-migrate with docker-compose?

In golang-migrate's documentation, it is stated that you can run this command to run all the migrations in one folder. docker run -v {{ migration dir }}:/migrations --network host migrate/migrate ...
2
votes
1answer
36 views

Go Dep - Missing sub-package “chi/middleware” after dep ensure

Missing middleware subpackage from go-chi after running dep ensure. project-backend | main.go:8:2: cannot find package "github.com/go-chi/chi/middleware" in any of: project-backend | /go/...
0
votes
1answer
24 views

Mongodb-go-driver interface conversion: interface {} is primitive.ObjectID, not primitive.ObjectID (types from different packages)

I can display the result.InsertedID with no problem, however, I keep getting the above error when I attempt to access the value to use it other places. I want to get the value before I leave the ...
0
votes
1answer
19 views

Query a index in dynamo db using golang

I need an example in golang on how to do a query on an index in dynamo db. https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SQLtoNoSQL.Indexes.QueryAndScan.html the one above is for ...
1
vote
1answer
55 views

Overhead for Golang's logger if set to discard

I have a HTTP handler that has 40 loggers that is set to os.Stdout. It works just fine for me as I am the only one testing at the moment. But, when it goes to the production, I'm afraid it will have ...
0
votes
0answers
13 views

Go Get for Google's Cloud Source Repository

Making two different go modules source.cloud.google.com/me/a source.cloud.google.com/me/b With source.cloud.google.com/me/common as a common lib dependency (to share a model) I'm trying to go get ...
0
votes
0answers
53 views

Correct way to import files in the same project in Go

I have a Go project with a structure like this: cmd myapp main.go internal app myapp impl.go Now in main.go, I want to import impl.go. GoLand tells me that I should do it like this:...
0
votes
3answers
50 views

Turning a file with string key/values into a Go map

I have a file that contains string key / value pairs separated by an = sign. It looks like this: "some.key" ="A cool value."; "some.other.key" ="A cool value with %@ chars and \n. Another Thing."; ...
0
votes
0answers
24 views

Using ctypes in Google App Engine to use Binaries?

I was trying to do interfacing between GoLang & Python. I have been a long time fan of Python and love using it. But Over Time I have udnerstood it is really bad for doing computations etc. ...
1
vote
0answers
12 views

How to invoke an “external” action based on a javascript call

on a golang/webview application, I need to be able to call an external application when a certain javascript call is rendered on the web application. I have been using https://github.com/zserge/...
1
vote
1answer
45 views

Out of Memory when using Golang method in Python

I have been following this https://medium.com/learning-the-go-programming-language/calling-go-functions-from-other-languages-4c7d8bcc69bf Now, what I am doing is:- Pass a Json String Use Json ...
3
votes
1answer
28 views

Go can't find file while running as a systemctl service on Ubuntu

I have a Go app, and I'm trying to run it as a systemctl service (Ubuntu 18.04). I'm using godotenv: func init() { var env map[string]string env, err := godotenv.Read() if err != nil { ...
1
vote
0answers
24 views

How to check logs generated through logrus, to get a count of the no. of errors and warnings

I wanted to a way through which we could keep the count of no. of errors and warnings that have occurred in logrus logs. I want to use a struct to keep count of the errors and warnings, type ...
1
vote
0answers
36 views

Incremental builds not working with go build, only with go install

I'm running a project using Go Modules with 1.11.4 on Ubuntu, running in WSL. My problem is that I'm having getting incremental builds to work as I expect. Perhaps this is due to me misunderstanding ...
0
votes
1answer
51 views

Ensure specific characters are in a string, regardless of position, using a regex in Golang

I am building a super simple function to ensure a password contains specific characters. Namely, the password should have the following: One lowercase letter One uppercase letter One digit One ...
-3
votes
0answers
44 views

Is this possible to assign other package struct in golang global variable and call dynamically?

File1.go file I added few struct with some attributes packageOne/File1.go package packageOne type exampleOne struct{ Id string Name string } type exampleTwo struct{ Street string ...

http://mssss.yulina-kosm.ru