[go-nuts] Re: encoding/gob decode []byte to multi struct types

2017-01-17 Thread caspian46
First thanks for you reply. Because in fact, I have about more than 10 different struct types (maybe more and more), your suggest is good, this is better type Info struct{ typeStr string // store the type info to decode IData IData interface{} } But I don't like to send the typeInfo

[go-nuts] Re: Marshal more than one XML line?

2017-01-17 Thread Tomi Häsä
What is the difference between Encoder and MarshalIndent? They both write to a stream. When do you use Encoder? On Tuesday, January 17, 2017 at 9:40:55 PM UTC+2, howar...@gmail.com wrote: > > If you actually run that example (click Run below it), you will see it is > actually writing out eleven

[go-nuts] Re: encoding/gob decode []byte to multi struct types

2017-01-17 Thread Felipe Spinolo
Why not just create a wrapper struct? Something like: type Mixed struct{ A *A B *B } And then just encode/decode that? On Tuesday, January 17, 2017 at 1:16:37 PM UTC-8, casp...@gmail.com wrote: > > I got two struct types encoded into bytes by gob, I want to decode the > bytes into a

[go-nuts] Re: Applying idiomatic Golang patterns to other languages?

2017-01-17 Thread Felipe Spinolo
I think it's a mistake to try to apply one language's idioms to another language. I don't write Go the way I would write Java or Python, and I don't write either of them the way I would write Go. Idiomatic Go is idiomatic because it fits with the design and philosophy of Go. On Monday,

Re: [go-nuts] exec.Command("cp", "-r", "./*.json", artifact.dir fails with exit status 1

2017-01-17 Thread Matt Harden
In Go, don't try to combine those actions into a single line. Also you shouldn't ignore the error from filepath.Abs. On Tue, Jan 17, 2017 at 11:14 AM Deepak Jain wrote: > I fixed the error by invoking Copy command with abs source path. > > srcPath, _ := > e :=

Re: [go-nuts] [ANN] - BoltHold - An embeddable NOSQL store for Go Types built on BoltDB

2017-01-17 Thread Tim Shannon
FYI, I've just released a new version which adds things like Skip and Limit to queries so you can have proper pagination now, and You can now create Aggregate queries to find things like Min, Max or group records. https://github.com/timshannon/bolthold On Thursday, November 17, 2016 at 3:55:27

[go-nuts] Re: Anatomy of a go web application

2017-01-17 Thread Tim Shannon
FYI, I've added a second post that gives some specifics on Authentication and password handling, if anyone is interested. http://tech.townsourced.com/post/anatomy-of-a-go-web-app-authentication/ On Sunday, December 4, 2016 at 10:36:45 PM UTC-6, DrGo wrote: > > Thanks Tim, > Very nice overview

Re: [go-nuts] shiny: get mouse position relative to window

2017-01-17 Thread ktye
That's a good hint. I can confirm that on linux everything works as expected. The issue is only on windows. The problem is only with mouse wheel events: https://github.com/golang/exp/blob/master/shiny/driver/internal/win32/win32.go#L168 lparam is used to get the coordinates of the mouse events.

[go-nuts] Re: How hard it is to write android app in Go if compare to traditional Java SDK (nowadays) ?

2017-01-17 Thread fsn761304
Thanks a lot for such detailed info ! Do you mean 48 hours literally or you was busy several hours couple of days. On Friday, January 13, 2017 at 10:05:46 AM UTC+4, Egon wrote: > > On Friday, 13 January 2017 01:14:18 UTC+2, fsn7...@gmail.com wrote: >> >> Let's say I wanna create 2D game in Go,

Re: [go-nuts] shiny: get mouse position relative to window

2017-01-17 Thread Dave MacFarlane
That doesn't sound right to me. I just added a 'fmt.Printf("X: %v Y: %v\n", e.X, e.Y)' to the switch case handling mouse.Event in one of my shiny programs, and the mouse coordinates are reported relative to the top-left corner of the window. On Sat, Jan 14, 2017 at 5:59 AM,

[go-nuts] encoding/gob decode []byte to multi struct types

2017-01-17 Thread caspian46
I got two struct types encoded into bytes by gob, I want to decode the bytes into a specific struct, is it possible without try all struct types(maybe 3 or more struct types)? I want to decode bytes without specify which elem in mixedBytes is struct A, and which is struct B. This is the

Re: [go-nuts] Re: best working and maintaned golang oauth2 server package

2017-01-17 Thread Rithu John
Hi Simon, The coreos/go-oidc package enables OpenID Connect support for the golang.org/x/oauth2 package.( https://github.com/coreos/go-oidc). You can look through the examples ( https://github.com/coreos/go-oidc/tree/master/example) to get a better idea of

[go-nuts] Re: Marshal more than one XML line?

2017-01-17 Thread howardcshaw
If you actually run that example (click Run below it), you will see it is actually writing out eleven lines of XML. If you had two persons, then you would not be marshalling each individually, generally. Instead, you would marshal a slice or array of persons. See this example:

Re: [go-nuts] exec.Command("cp", "-r", "./*.json", artifact.dir fails with exit status 1

2017-01-17 Thread Deepak Jain
I fixed the error by invoking Copy command with abs source path. srcPath, _ := e := util.Copy(srcPath, dst) If i could modify into a single line util.Copy(filepath.Abs(filepath.Dir(src)), dst) Throws error as filepath.Abs(filepath.Dir(src)) returns a tuple. In scala i can use _1, _2 to

Re: [go-nuts] exec.Command("cp", "-r", "./*.json", artifact.dir fails with exit status 1

2017-01-17 Thread Deepak Jain
Thanks for pointing to https://github.com/juju/utils/blob/master/fs/copy.go I was testing Copy function that recursively copies directories. I am able to copy first level of files and it creates directories. It fails to copy the contents within those directories. func Copy(src, dst string)

[go-nuts] Marshal more than one XML line?

2017-01-17 Thread Tomi Häsä
On page https://golang.org/pkg/encoding/xml/#MarshalIndent there is an example how to write to a file one line of XML, but there is no explanation if I have more than one line. In Go are you supposed to write one line at a time like in C++ or everything at the end? I.e. if I have two persons

[go-nuts] Re: Test code that interacts with private variables and doesn't bloat binary

2017-01-17 Thread C Banning
See TestMain() documentation in "Overview" for https://golang.org/pkg/testing/ On Tuesday, January 17, 2017 at 12:28:34 AM UTC-7, alcub...@gmail.com wrote: > > I'm trying to test my packages without bloating the size of the binary. > Currently this consists of moving the test code into a test/

Re: [go-nuts] Re: best working and maintaned golang oauth2 server package

2017-01-17 Thread Vasiliy Tolstov
Thanks for link.does this library good for my use-case? Also does it possible to have server without static assets? 17 Янв 2017 г. 18:55 пользователь "Brandon Philips" написал: Hey Simon- Any reason you aren't using Dex? https://github.com/coreos/dex Brandon On Wed, Jan 11,

Re: [go-nuts] Re: best working and maintaned golang oauth2 server package

2017-01-17 Thread Brandon Philips
Hey Simon- Any reason you aren't using Dex? https://github.com/coreos/dex Brandon On Wed, Jan 11, 2017, 12:08 PM Simon Ritchie wrote: > I've just started work on an OAUTH server too. So far I've built the > "simple" example of the RangelReale project. It takes a

Re: [go-nuts] HTTP Server - Force close connection after response

2017-01-17 Thread James Bardin
Sorry, google groups UI doesn't make it clear that this was in response to Tony's last message. `Connection: close` tells the client that the connection *will be closed*, it doesn't request that the client close the connection. Just set `Connection: close` and the server will do the right

[go-nuts] Re: HTTP Server - Force close connection after response

2017-01-17 Thread cat2neat
I think Calling https://golang.org/pkg/net/http/#Server.SetKeepAlivesEnabled given false should work what you want. (You would need to use https://golang.org/pkg/net/http/#Server instead of using ServeMux directly) 2017年1月17日火曜日 12時36分27秒 UTC+9 Tony Grosinger: > > I would like to create an

Re: [go-nuts] Re: Help translate x86-64 assenbly to Go assembly

2017-01-17 Thread lars
Thanks, Damian Gryski has a nice tutorial on how to write Go assembly functions with PeachPy. https://blog.gopheracademy.com/advent-2016/peachpy/ On Tuesday, January 17, 2017 at 11:43:11 AM UTC+1, Peter Waller wrote: > > A useful tool for this in general is >

Re: [go-nuts] Re: Help translate x86-64 assenbly to Go assembly

2017-01-17 Thread Peter Waller
A useful tool for this in general is https://github.com/Maratyszcza/PeachPy/ It will even generate BYTE directives if the go assembler doesn't support the instruction you want to use. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] Reading an .ini file

2017-01-17 Thread Konstantin Khomoutov
On Sat, 14 Jan 2017 08:03:45 -0800 (PST) buc...@gmail.com wrote: > Rankest beginner here. Trying to learn Go by converting an old > Visual Basic application to Go (yeah, right) on Windows 10 (got all > the database stuff working with both postgre and sqlite!) The > application needs to read an

[go-nuts] Re: Test code that interacts with private variables and doesn't bloat binary

2017-01-17 Thread alcubecker
Ah, then my fundamental structure was wrong. Since the code didn't contain any tests, I had it in a file named init_mock.go, and it was getting pulled into the binary. So you're saying I should have all test-only code in a file named *_test.go, including code that doesn't contain any tests? On