1 answer

Using Go (protobuf API) to read a new csv file everyday

My protobuf is a CSV file that I receive through an API. I've written most of the code for this but am lost with how to deal with making my code work with a new CSV file everyday Here is the sample ...

0 answers

unable to run golang as background service using upstart

I want to run my golang server as background service and I have these lines of code in my /etc/init/api.conf start on filesystem or runlevel [2345] stop on runlevel [!2345] env USER='ec2-user' ...

20 mins ago by Jon Snow on Stack Overflow
1 answer

How to modify fields of a Golang struct to another type before rendering to jSON?

We are adding an include parameter in our API w/c API clients can use to include relationships // request GET /api/events?include=team1 [{ "id": <event_id>, "name": <event_name>, ...

1 answers | 25 mins ago by John Kevin M. Basco on Stack Overflow
0 answers

Golang GORM pq too many connections

I am using GORM golang on my project, everything is good until I got error that said : pq: sorry, too many clients already I just use the default configuration. The error happen after I did a lot ...

2 answers

AES-CTR Encrypt in CryptoJS and decrypt in Go lang

I have a problem decrypting text, which is encrypted in Go lang, with CryptoJS. Here is Go code: package main import ( "crypto/aes" "crypto/cipher" ...

1 answer

How can I properly write the `Read` and `Write` the `net.Pipe()`

I'm trying out the net.Pipe(). I thought writing the "haha" string and then reading it back might be a good experiment. Here is my first version. It blocks on the Write func TestNetPipe(t ...

1 answers | 1 hour ago by zjk on Stack Overflow
0 answers

How can I design a method signature which is equivalent to goquery's Find(selector string), but adding timeout feature?

I'm using goquery in goreadability, Go port of arc90's readability project. I found bottleneck on document.Find("*") when a document is abnormally big (ex: I think ...

1 answer

Golang - Don't escape in HTML templates

Trying to render HTML templates for sending via email with embedded attachments with cid:. Problem is, that Go does escaping and I cannot do anything. tplVars := map[string]interface{}{ "Dog": ...

3 answers

Why is this function undefined when I run `go test`?

Here is the code a.go package main import "fmt" func Haha() { fmt.Println("in Haha") } func main() { } a_test.go package main_test import "testing" func TestA(t *testing.T) { Haha() ...

3 answers | 3 hours ago by zjk on Stack Overflow
2 answers

How to replace all characters in a string in golang

package main import ( "fmt" "strings" ) func main() { fmt.Println(strings.Replace("golang", "g", "1", -1)) } How to replace all characters in string "golang" (above string) by * that ...

2 answers | 4 hours ago by vijay on Stack Overflow
2 answers

Is it always okay to use variables concurrently in Go?

I'm writing a small webserver program, and it does a lot of JSON decoding from POST requests coming in. Initially I thought that instead of initializing a new json.Decoder every time a request comes ...

2 answers | 4 hours ago by Doug Smith on Stack Overflow
2 answers

I need to connect to an existing websocket server using go lang

Theres a websocket running in my localhost on ws://localhost:8080/ws I need go lang code that can create a websocket client and connect to this server. My Google-Fu skills failed to teach me a ...

2 answers | 4 hours ago by SudoPlz on Stack Overflow
1 answer

How do you install Go dependencies when deploying to Elastic Beanstalk?

I have an application that's split across a few different files and I'm having trouble deploying it. I've followed this documentation, but I'm getting the following: application.go:7:5: cannot find ...

1 answer

Watch recursive directories in go-inotify

I am using this go library for file and folder watcher in Linux inotify when we use directly in Linux it gives one parameter to be passed to watch recursive ...

1 answers | 5 hours ago by Shilpi Agrawal on Stack Overflow
0 answers

Reverse Proxy with Multiple Hosts using Go

I'm trying to setup a reverse proxy with multiple hosts using Go. This is my first Go project so I'm unsure if I am on the correct path. The goal is to setup a gateway server that receives requests ...

3 answers

Difference between http and default servemux?

What's the difference between this: func main() { http.HandleFunc("/page2", Page2) http.HandleFunc("/", Index) http.ListenAndServe(":3000", nil) } And using the golang serve mux func main() ...

3 answers | 5 hours ago by DangMan on Stack Overflow
2 answers

Counting characters in golang string

I am trying to count "characters" in go. That is, if a string contains one printable "glyph", or "composed character" (or what someone would ordinarily think of as a character), I want it to count 1. ...

0 answers

Go with C code compilation on Windows

I am trying to compile my Go code that has to be statically linked to C/C++ later. Apparently the latest Go 1.6.2 does not work for any builds on Windows that are not producing executable file ...

1 answer

Appending to multiple instances of a slice

If I have two pointers to slices s1, s2, which initially point to the same slice, is it possible to append to one of the slices and have the other slice also point to the updated slice? This seems to ...

1 answers | 7 hours ago by George on Stack Overflow
1 answer

how to change process (application) priority from Normal to Low Programmatically in Golang

How to change Process Priority Class Programmatically in Golang? I have CPU intensive task and I want system and user programs have higher priority so my Golang application run only when the system is ...

1 answers | 7 hours ago by Ramsey PhD on Stack Overflow
0 answers

Facebook Oauth CORS error

I am using oauth2 to handle a user login via facebook. The error occurs when I call the authorization server in the golang api. Here is the network error. Fetch API cannot load ...

2 answers

GoLang: How to embed a map into a struct so that it has a flat json representation?

In order to create a table-like structure, I serialized my row data in following format in my previous application: { "key1": "...", "key2": "...", "15/04": 1.3, "15/05": 1.2, .... "17/08": 0.8 } ...

1 answer

strconv.Atoi() throwing error when given a string

When trying to use strconv on a variable passed via URL(GET variable named times), GoLang fails on compilation stating the following: multiple-value strconv.Atoi() in a single-value context ...

1 answers | 10 hours ago by dead beef on Stack Overflow
2 answers

Embedding a map into a struct in the go language

So in this answerhere, it's stated that one cannot embed a map into a struct in go. However, I was fiddling around with it, and came up with this and it does actually work, and is pretty straight ...

2 answers | 10 hours ago by Josh Weinstein on Stack Overflow
1 answer

Golang websocket handler

I've started learning Golang after writing in Node.js for a long time and I'm a bit curious as to how am I to implement a handler - I've opted to use Gorilla Websocket since I understood it's the most ...

0 answers

How to get data from HTTP server in JSON format(golang)

I had to parse a XML feed from file.xml,and to store found listings in a persistent storage. Now I have to expose listings using HTTP server in JSON format in Go(golang). Any help??? package main ...

1 answer

How can I unit test a goroutine that runs on an infinite for loop using sync.Cond?

I am trying to unit test a channel that runs on an infinite for loop. I think I've found a way to do it, but I'm not sure if it's a valid way to use conditional variables. Also I'm not sure if this ...

1 answers | 14 hours ago by circuitry on Stack Overflow
0 answers

Ho to get PID of browser running as Selenium Remote WebDriver?

I use golang client for Selenium ( and can use only Remote WebDriver. Is it possible to get PID of running browser? caps := selenium.Capabilities{"browserName": "firefox"} ...

2 answers

Go file names starting with underscore character

I wanted a specific file to appear at the top of my file list in my editor, so I prefixed it with _. This is how it looks: mypkg _func.go a.go b.go I know about Go's file naming conventions ...

2 answers | 15 hours ago by Erik Aigner on Stack Overflow
4 answers

Easy way to check string is in json format in golang?

I want to create a function to receive an input string which can be string in json format or just a string. For example, something easy like following function. func checkJson(input string){ if ...

4 answers | 16 hours ago by A-letubby on Stack Overflow
15 30 50 per page
1 2 3