[go-nuts] Will database/sql leak memory if I don't call Close() and remove references to it?

2016-10-31 Thread Francis Chuang
I want to use Vault to manage and rotate the usernames and passwords to my databases. If I open a connection: db, err := sql.Open("mysql", ""), and then later on, open a new connection due to the username/password being rotated: db, err =

Re: [go-nuts] folder and package structure with ddd based micro services

2016-10-31 Thread Peter Bourgon
You might want to take a look at https://github.com/marcusolsson/goddd and https://github.com/go-kit/kit/tree/master/examples/shipping. On Mon, Oct 31, 2016 at 12:02 PM, JM wrote: > im building a micro service layer using the following folder structure. I > have unit tests

[go-nuts] Re: folder and package structure with ddd based micro services

2016-10-31 Thread Diego Medina
Hi, > How can i run my tests "go test" for my entire domain model is they are > in sub folders? > If I understood your question, what you are looking for is to run go test ./... at the root, that will run tests at the root but also tests in the subfolders Regards, Diego > >

[go-nuts] type assertion: Can I DRY this up?

2016-10-31 Thread wwarner
Hello all, I'm new to Go, and I have a question about identifying types as they're encountered in traversing a map[string]interface{}. I've ended up with a big sieve of type assertions something like this: if mt.Mi, ok = m.(map[string]int); ok { nval, ok = mt.Mi[mk]

[go-nuts] Append function overwrites existing data in slice

2016-10-31 Thread Tobias Wellnitz
Hi, I wrote a small application which records data from a sound card and stores the data in an array for later processing. Whenever new data is available, portaudio executes the a callback. Within the callback I append the data to an array. The golang builtin function append adds as expected

[go-nuts] Go-Routine, Concurrency Doubt

2016-10-31 Thread Sadhasivam Jayabalaganesan
Hi Folks, Love to watch more and more code reviews like this ( https://www.youtube.com/watch?v=eIWFnNz8mF4 ) from Francesc Campoy. while watching the code review i got a very silly doubt in the following code snippet. Assume I have Ten tasks & set concurrency value to be 10. would that be

[go-nuts] Custom collation

2016-10-31 Thread Jonathan Hall
I need to collate some IPA transcriptions, which means that following the standard collation rules for a given language doesn't really make sense. As such, I wish to define my own collation order. Is there any documentation, howto, or other easier-to-digest documentation on this than what

Re: [go-nuts] Working with characters in strings

2016-10-31 Thread 'Thomas Bushnell, BSG' via golang-nuts
Sorry, I did not mean to say they are restricted to UTF8. I was answering the question "what is the relation between a rune and its byte representation", by saying that the []byte cast of a string (assuming the string only holds legitimate runes) is the UTF8 of the runes making it up. The

Re: [go-nuts] Working with characters in strings

2016-10-31 Thread Lars Seipel
On Mon, Oct 31, 2016 at 06:06:23PM +, 'Thomas Bushnell, BSG' via golang-nuts wrote: > Strings are specified to be UTF8, so if you cast a string to []byte you > will see its UTF8 representation. They are not. A Go string may contain arbitrary bytes. Features like for..range or conversions to

Re: [go-nuts] bug? if true &&& true &&& false {

2016-10-31 Thread mhhcbon
sorry i dont share your enthusiast for this exercise :s And tbhonnest, again, i never use most of those operators. And if you d write this kind of thing in my sources, i d go format them immediately!! On Monday, October 31, 2016 at 9:56:13 PM UTC+1, Pietro Gagliardi (andlabs) wrote: > > In

[go-nuts] Re: bug? if true &&& true &&& false {

2016-10-31 Thread mhhcbon
TBHonnest, i know very little about parser. The only parser i ever wrote are those two, yet not really by myself (*BTW*, I Hope someday Mr.Pike will do more video like the one quoted in this repo) https://github.com/mh-cbon/state-lexer https://github.com/mh-cbon/html-parser-lexer Given my very

Re: [go-nuts] bug? if true &&& true &&& false {

2016-10-31 Thread Pietro Gagliardi
(that second half was also addressed to the OP) > On Oct 31, 2016, at 5:08 PM, Pietro Gagliardi wrote: > > Not sure if you were addressing me or the OP. > > If me: Of course; that is the realization that comes once you understand how > leftmost longest matching works :) My

Re: [go-nuts] bug? if true &&& true &&& false {

2016-10-31 Thread Pietro Gagliardi
Not sure if you were addressing me or the OP. If me: Of course; that is the realization that comes once you understand how leftmost longest matching works :) My email was written from the standpoint that the source of the confusion was the expectation that tokens were *only* delimited by

Re: [go-nuts] bug? if true &&& true &&& false {

2016-10-31 Thread Jan Mercl
On Mon, Oct 31, 2016 at 9:48 PM Pietro Gagliardi wrote: > In Go, as in most languages, spaces do not *have to* delimit tokens. A token ends when the leftmost longest matching token is found, and the rest is placed back in the input buffer for the next token. FTR: The

Re: [go-nuts] bug? if true &&& true &&& false {

2016-10-31 Thread Pietro Gagliardi
In addition, here's a few exercises. What do the following get tokenized as? &^== &&^ <<- ++= -&^ /^* > On Oct 31, 2016, at 4:48 PM, Pietro Gagliardi wrote: > > In Go, as in most languages, spaces do not *have to* delimit tokens. A token > ends when the leftmost longest

Re: [go-nuts] CGO: Go string -> void*/length

2016-10-31 Thread Pietro Gagliardi
I was going by the example at the bottom of the OP. Use whatever type is expected by the C API, of course. > On Oct 31, 2016, at 4:41 PM, Florian Weimer wrote: > > * Pietro Gagliardi: > >> Just pass the null-terminated string and use C.int(len(goString)) as >> the length.

Re: [go-nuts] bug? if true &&& true &&& false {

2016-10-31 Thread Pietro Gagliardi
In Go, as in most languages, spaces do not *have to* delimit tokens. A token ends when the leftmost longest matching token is found, and the rest is placed back in the input buffer for the next token. So &&& true 1) read & — this can be &, &=, &&, &^, or &^=, so read again

Re: [go-nuts] CGO: Go string -> void*/length

2016-10-31 Thread Florian Weimer
* Pietro Gagliardi: > Just pass the null-terminated string and use C.int(len(goString)) as > the length. The length of a Go string is already in bytes and does not > include the terminating null (since Go has none), and I assume > C.CString() produces the same byte sequence without encoding >

Re: [go-nuts] bug? if true &&& true &&& false {

2016-10-31 Thread Rob Pike
Gofmt will regroup it; golint not required. -rob On Mon, Oct 31, 2016 at 1:35 PM, 'Paul Borman' via golang-nuts < golang-nuts@googlegroups.com> wrote: > Sounds like a golint sort of thing. > > On Mon, Oct 31, 2016 at 1:26 PM, Jan Mercl <0xj...@gmail.com> wrote: > >> >> On Mon, Oct 31, 2016 at

Re: [go-nuts] bug? if true &&& true &&& false {

2016-10-31 Thread 'Paul Borman' via golang-nuts
Sounds like a golint sort of thing. On Mon, Oct 31, 2016 at 1:26 PM, Jan Mercl <0xj...@gmail.com> wrote: > > On Mon, Oct 31, 2016 at 8:45 PM wrote: > > > the triple ampersands is parsed as : > > true && > > Correct. That's what the specs prescribe. > > > No syntax error is

Re: [go-nuts] bug? if true &&& true &&& false {

2016-10-31 Thread Jan Mercl
On Mon, Oct 31, 2016 at 8:45 PM wrote: > the triple ampersands is parsed as : > true && Correct. That's what the specs prescribe. > No syntax error is reported :/ &&& is not intended, its a typo and should be reported so. There's no syntax error in it. The errors produced

Re: [go-nuts] Re: Unexpected lack of parallel speedup

2016-10-31 Thread Florian Weimer
* Chris Kastorff: > If your program is spending that much time in GC, then you're likely > spending a lot of time with the pointer write barriers on, which slow > execution (for the benefit of having your code run at all during GC.) Well, it's creating a lot of garbage, so I can't really

[go-nuts] bug? if true &&& true &&& false {

2016-10-31 Thread mhhcbon
Hi, noticed that an instant ago, package main import ( "fmt" ) func main() { if true &&& true &&& false { fmt.Println("ok") } } Gives this output, tmp/sandbox074568120/main.go:8: cannot take the address of true > tmp/sandbox074568120/main.go:8: invalid operation: true &&

[go-nuts] folder and package structure with ddd based micro services

2016-10-31 Thread JM
im building a micro service layer using the following folder structure. I have unit tests for everything and each if store in it's relative folder. I am thinking of moving everything in my domain model into one root folder and not have sub folders for each. then just have NewAggregate1

Re: [go-nuts] Working with characters in strings

2016-10-31 Thread 'Thomas Bushnell, BSG' via golang-nuts
I don't know what you mean by "characters", since you're distinguishing them from runes. Do you mean bytes? Strings are specified to be UTF8, so if you cast a string to []byte you will see its UTF8 representation. Thomas On Sat, Oct 29, 2016 at 4:42 AM wrote: > > I

Re: [go-nuts] Re: Unexpected lack of parallel speedup

2016-10-31 Thread Chris Kastorff
If your program is spending that much time in GC, then you're likely spending a lot of time with the pointer write barriers on, which slow execution (for the benefit of having your code run at all during GC.) What happens if you run with GODEBUG=gcstoptheworld=1? That should help the GC run

[go-nuts] Re: Building Go 1.7.3 from source on windows

2016-10-31 Thread Henry
Hi Dave, Thanks for pointing towards the right direction. I did some major cleanups on my machine and sorted out the environment variables. The build went smoothly afterwards with all tests passed. I guess it was time to clean up the machine anyway. Thanks again. :) Henry On Monday, October

Re: [go-nuts] CGO: Go string -> void*/length

2016-10-31 Thread James Bardin
C.CBytes does essentially this, but you either need to start with a []byte, or the string conversion could be a second copy. I don't see a need for a separate version CString without the null when you can just pass the length-1. In the rare case that the extra byte makes a difference, you

Re: [go-nuts] CGO: Go string -> void*/length

2016-10-31 Thread Peter Mogensen
On 2016-10-31 15:39, Pietro Gagliardi wrote: Just pass the null-terminated string and use C.int(len(goString)) as the length. Yes... I mentioned that as a somewhat solution. ... it still allocates 1 byte more than needed. /Peter -- You received this message because you are subscribed to

[go-nuts] Re: Stalking people online for thought crimes! This is what the Go project has succumbed to!

2016-10-31 Thread Tong Sun
I totally agree. I *am *afraid to say anything there. The culture there is so different than here, just look at the previous responses to this message and you sure will understand that. (and I'm afraid I'll be flamed for this response as well) Thus I second to exclude it from any official go

Re: [go-nuts] CGO: Go string -> void*/length

2016-10-31 Thread Pietro Gagliardi
Just pass the null-terminated string and use C.int(len(goString)) as the length. The length of a Go string is already in bytes and does not include the terminating null (since Go has none), and I assume C.CString() produces the same byte sequence without encoding conversions. > On Oct 31,

[go-nuts] CGO: Go string -> void*/length

2016-10-31 Thread Peter Mogensen
Hi, I was trying to find the official way to pass a Go string to CGO code as a void* (or char*) with explicit length. ... using only one allocation/copy. I could probably just call C.CString(string) and ignore the extra \0 added by CGO, but I'm a little puzzled that there's not a shorthand

Re: [go-nuts] can't understand sync.RWMutex documentation

2016-10-31 Thread Roberto Zanotto
As I understood it: Normally, when two (or more) goroutines call RLock, they can acquire the read lock simultaneously without problem. But, you cannot assume that this property always holds (see Caleb's example). If your algorithm relies on two goroutines holding the read lock at the same time,

[go-nuts] FYI, the GO jsonfile package that wraps around saving and reading JSON files

2016-10-31 Thread Tong Sun
*GO jsonfile package that wraps around saving and reading JSON files* https://github.com/go-jsonfile/jsonfile This package provides simple wrapping around saving and reading JSON files (streams) in GO. It exists because way too many sample/demo code are doing it the wrong way. Wrong in the

[go-nuts] Re: Not able to pass Bearer token in headers of a GET request in Golang

2016-10-31 Thread Christian Joergensen
Hi, Have you tried inspecting the network traffic? Does the request contain the extra header? What's urlfetch? Cheers, On Monday, October 31, 2016 at 1:35:00 PM UTC+1, Tahir Rauf wrote: > > I am using oauth2 to access a third party API. I can get the access token > alright, but when I try

Re: [go-nuts] can't understand sync.RWMutex documentation

2016-10-31 Thread seafooler
I cannot still get it! Could you explain it to me? Thanks ahead 在 2016年10月4日星期二 UTC+8上午5:28:11,Roberto Zanotto写道: > > I get it now. Thanks for your time. > > On Monday, October 3, 2016 at 10:55:34 PM UTC+2, Caleb Spare wrote: >> >> It's explained in the text afterwards: >> >> "This is to ensure

[go-nuts] Not able to pass Bearer token in headers of a GET request in Golang

2016-10-31 Thread Tahir Rauf
I am using oauth2 to access a third party API. I can get the access token alright, but when I try to call the API by passing the bearer token in the request headers it gives me 401 (Unauthorized) error. Although it works well when I try to do it via POSTMAN by passing headers as

[go-nuts] Re: [golang-dev] Re: Issue with gonum/plot and golang playground

2016-10-31 Thread Seb Binet
(bcc: golang-dev cc: golang-nuts) On Sat, Oct 29, 2016 at 10:31 PM, wrote: > Hey, I wrote a tiny helper module to show images like imshow in python and > matlab. https://github.com/nnvn/imdisp > FYI, I have also this gonum/plot backend to