1 answer

Parsing form arrays In Go

I need to be able to to something like this in my HTML forms: <form method="POST"> <input type="text" name="cart[items][1][qty]" value="3"/> <input type="text" ...

1 answers | 2 hours ago by Dac0d3r on Stack Overflow
1 answer

golang create dynamically receiver inside switch

I would like read, extract and save data from different sources with Read and Write methods implemented in Process interface The code works rigth in the first example: type Process interface { ...

0 answers

Where should I add logging in my Go web scraper?

I'm writing a suite of website scraper functions. Each function reads an HTML document and returns a single value. To tie this all together, I've got a function - let's call it ScrapeUrl that accepts ...

1 answer

How to pass arguments correctly to syscall (git)?

I am trying to clone a git repository by calling git via syscall. (I know there is git2go but that's not what I want. I definitely want to do a syscall) git, lookErr := exec.LookPath("git") if ...

1 answers | 6 hours ago by udondan on Stack Overflow
3 answers

How to unmarshal two json with same internal structure into one single golang struct?

I have two json files with following structure { "cast": [ { "url": "carey-mulligan", "name": "Carey Mulligan", "role": "Actress" }, { ...

3 answers | 7 hours ago by Mayank Patel on Stack Overflow
1 answer

How to unmarshal two json values into same variable?

I frequently come across json that have same structure but different name. How is it possible to assign all of them in same struct. for example { "e":"g" "a":[ { "b":"b1", ...

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

os.Open on AppEngine with Go

I've recently started playing a bit with AppEngine but I'm having problems opening a file. Here's the code I'm using: if _, err := os.Open("/pizza.webp"); err != nil { printError(err.Error()) } ...

1 answers | 8 hours ago by raulsntos on Stack Overflow
1 answer

PHP can't decompress gzip data by Golang

Why can't decompress gzip data by Go in my PHP demo, but PHP gzip data to Go is successful? I need post gzip JSON data from Go to PHP API service. Test result -> | php | go ...

1 answers | 9 hours ago by gopheryu on Stack Overflow
0 answers

Gorilla mux router not working for particular route

I'm having an issue using Gorilla for routing. For some routes it works fine, but for other it does not. I have the following code: import ( "" ...

1 answer

Accessing Nested Map of Type map[string]interface{} in Golang

So I'm trying to parse a JSON response. It can be multiple levels deep. This is what I did: var result map[string]interface{} json.Unmarshal(apiResponse, &result) Firstly, is this the right way ...

2 answers

How can I check for errors in CRUD operations using GORM?

The official documentation for GORM demonstrates a way in which one can test for the existence of a record, i.e.: user := User{Name: "Jinzhu", Age: 18, Birthday: time.Now()} // returns true if ...

2 answers | 16 hours ago by blz on Stack Overflow
1 answer

How fast is the go 1.5 gc with terabytes of RAM?

Java cannot use terabytes of RAM because the gc pause is way too long (minutes). With the recent update to the go gc, I'm wondering if its gc pauses are short enough for use with huge amounts of RAM, ...

1 answer

Beego: How to redirect to other page on session time out

i am handling session variable by setting time out using globalSessions, _ = session.NewManager("memory", `{"cookieName":"gosessionid", "enableSetCookie,omitempty": true, "gclifetime":5, ...

2 answers

Golang - Documentation On “All Known Implementation” of Interfaces

Few months into learning Go, I just discover that os.File implements the io.Reader interface by implementing the Read(b []byte) (n int, err error) function. This allows me to use a buffered reader to ...

2 answers | 19 hours ago by isim on Stack Overflow
1 answer

Do Go implementations store the length of a map?

Does a map have its length stored somewhere or is it calculated each time we call len(my_map)? The language spec shows this for maps, which doesn't really help: The number of map elements is ...

1 answers | 21 hours ago by Lye Fish on Stack Overflow
1 answer

Convert to time in Golang from milliseconds

I have a some json data where there is a field called lastModifed contains time in millis. I wanted to convert this data into a struct type with json.UnMarshaller. I have mapped the field with json ...

1 answers | 21 hours ago by Sadlil on Stack Overflow
3 answers

Go - how to explicitly state that a structure is implementing an interface?

Since Go puts a heavy emphasis on interfaces, I'm wondering how can I explicitly state that a structure is implementing an interface for clarity and errors checking in case some method is missing? I ...

1 answer

Postgresql Golang Martini Inserting key

I am working on building a social network type server as an exercise using martini, golang, and postgresql to help develop my skills in all three. The few key things that are eluding me are how to ...

0 answers

Golang: Port doesn't close when I run ListenAndServe() in a test function, how do I fix this?

When I call http.ListenAndServe() in a test function the port does NOT close even after the tests have finished and the process has terminated. So the next time I run the tests I get the error ...

1 answer

Golang GAE Save Image Url to Blobstore

I am looking to save an image in Go, something like this: url := "" response, e := http.Get(url) if e != nil { log.Fatal(e) } defer response.Body.Close() file, ...

1 answers | yesterday by Chris on Stack Overflow
0 answers

Getting EOF from known good csv file

I have been writing a program to parse a csv file using the encoding/csv package. For some reason I have begul getting sporadic EOF errors. It is very strange since I am using the same file to test ...

1 answer

Go doesn't release memory after http.Get

I am loading web pages using simple thread pool, while dynamically loading urls from file. But this this small program slowly allocate as much memory as my server has, until omm killer stops it. It ...

1 answers | yesterday by Denton on Stack Overflow
0 answers

Getting the URL parameter in Go issue

I have a URL that looks something like this: http://localhost/templates/verify?key=ijio My router looks like this: import ( "" "" ) ctx := ...

0 answers

Get remote ssl certificate in golang

I want to receive a TCP connection over TLS. I want to validate client certificate and use it to authenticate the client to my application. Go has the standard crypto/tls package. It can validate ...

4 answers

declare const array of floats

I have tried: const ascii = "abcdefghijklmnopqrstuvwxyz" const letter_goodness []float32 = { .0817,.0149,.0278,.0425,.1270,.0223,.0202, .0609,.0697,.0015,.0077,.0402,.0241,.0675, ...

4 answers | yesterday by demas on Stack Overflow
2 answers

How do I tell my test to wait for a callback in a goroutine?

I am using the dockerclient which has a channel-based API to listen for events client.MonitorEvents() and a convenient callback method ...

2 answers | yesterday by deitch on Stack Overflow
2 answers

Go timeout not firing

I implemented a few sorting algorithms in Go for fun, and now I'd like to test their performance on random integers. So I wrote the following program. I followed a similar format to: ...

2 answers | yesterday by Allan Pinkerton on Stack Overflow
3 answers

First class functions in Go

I come from JavaScript which has first class function support. For example you can: pass a function as a parameter to another function return a function from a function. Can someone give me an ...

1 answer

golang time.Sleep bug?

I make test code below(gotest.go) package main import ( "fmt" "time" "sync" ) func main() { var wg sync.WaitGroup wg.Add(1) go testa() wg.Wait() } func ...

1 answers | yesterday by user2139281 on Stack Overflow
2 answers

concurrency and timeout in Go

This Go program: package main import ( "fmt" "time" ) func main() { start := time.Now() sleep_durations := []int{8100, 1000, 2500, 500, 6000} // sleep_durations := []int{8100, ...

2 answers | yesterday by cLee on Stack Overflow
15 30 50 per page
1 2 3