Re: [go-nuts] Problem with code!

2016-11-28 Thread Seth Bunce
You may be missing a "continue" in your "if cont == 0" block. Seth On Nov 28, 2016 7:33 AM, "Sergio Hunter" wrote: > Hi everybody. I need help. When outputting data to a csv file, the dates > is duplicated, but should merge and be counted. How to write correctly? > Thanks. > > > > package main

Re: [go-nuts] Problem with code!

2016-11-28 Thread Shawn Milochik
Just a Go map -- like you're already using elsewhere in the code. It's the same as a hash in Perl or a dict in Python -- you can't have duplicate keys. So if you create a map that has the date as the key and anything as the value (an empty struct is idiomatic, but you can also use a boolean), then

Re: [go-nuts] Problem with code!

2016-11-28 Thread Sergio Hunter
I can't understand about "map", Could you explain me please? понедельник, 28 ноября 2016 г., 18:35:54 UTC+2 пользователь Shawn Milochik написал: > > The dates are just being appended without being checked for duplication: > > for userStats := range userStatsData.Dates { > date

Re: [go-nuts] Problem with code!

2016-11-28 Thread Shawn Milochik
The dates are just being appended without being checked for duplication: for userStats := range userStatsData.Dates { dates = append(dates, userStats) } You could use a map for this. Also, check your errors: data, _ = ioutil.ReadAll(r) If the first "if" block for th

[go-nuts] Problem with code!

2016-11-28 Thread Sergio Hunter
Hi everybody. I need help. When outputting data to a csv file, the dates is duplicated, but should merge and be counted. How to write correctly? Thanks. package main import ( "database/sql" "log" _"github.com/go-sql-driver/mysql" "compress/zlib" "bytes"