Re: [go-nuts] How do I test an func which depends on (pseudo)-random numbers, e.g. rand.Intn()?

2017-03-14 Thread Dan Kortschak
If you let randSpaceline take a *rand.Rand then you can control the source of the randomness and arbitrarily set the seed. You also get the advantage of having a non-mutex protected rand source if you don't need it (we do a similar thing and used rand. if the *rand.Rand is nil as a convenience).

[go-nuts] Re: How do I test an func which depends on (pseudo)-random numbers, e.g. rand.Intn()?

2017-03-14 Thread Miki Tebeka
IMO the right approach is as you suggested - seed once in init. init is called before your tests, so the seed you do in your test will override it. On Wednesday, March 15, 2017 at 5:45:22 AM UTC+2, Doug Ireton wrote: > > I'm a new Gopher and I'm working through "Learn Go" by Nathan Youngman >

[go-nuts] How do I test an func which depends on (pseudo)-random numbers, e.g. rand.Intn()?

2017-03-14 Thread Doug Ireton
I'm a new Gopher and I'm working through "Learn Go" by Nathan Youngman and trying to TDD the exercises to learn how to write testable Go code. I have a function to return a random spaceline from a string array. In Go, how do I test functions which depend

[go-nuts] for the fun, node stream like in go

2017-03-14 Thread mhhcbon
Totally not go-ish experiment about piping streams with go https://github.com/mh-cbon/poc-pipe I don t like that is breaks the static type check in one-two places like Piper.Pipe, besides that it was very interesting and educative. Also, after nth attempt on that matter, i m happy it can mix

[go-nuts] Conserving memory in TLS handshake and x509 certificate verification

2017-03-14 Thread Nathan Morley
Hello, So I've written a small service in my free time that essentially pulls data from a RESTful API at a high rate, and store it in a database. While there is no rate limiting in place and I'm free to hit it as hard as I like with as many connections I need, I only have 5 workers going at a

Re: [go-nuts] Re: Gracefully Shutdown File Server

2017-03-14 Thread Andrew
You are the expert, It works great! I may close the issue. Thank you very much! Andrew -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to

Re: [go-nuts] uint type safety in go

2017-03-14 Thread Ian Lance Taylor
On Tue, Mar 14, 2017 at 9:23 AM, Eyal Posener wrote: > Thanks for the answer. Very interesting. > About the run time cost, does go always prefer safety over efficiency? or > there is some kind of delicate balance between the two? I would say that Go favors safety, but there is

Re: [go-nuts] Re: Gracefully Shutdown File Server

2017-03-14 Thread Martin Schnabel
i looked into the issue and it seems the problem is the early exit from the program. this should work https://play.golang.org/p/LdXUYyzDxY On 14.03.2017 06:30, amk...@gmail.com wrote: Maybe this is a bug or need clear documentation about this. I've filed a bug report here:

[go-nuts] Re: go test error: cannot use matchString as type testing.testDeps in argument to testing.MainStart

2017-03-14 Thread Sathish VJ
Aaah, got it. I had updated GOROOT for 1.8 and then hadn't changed it back. sorry for wasting your time. But I found the solution long after I faced it but as soon as I posted it publicly. Figures. On Wednesday, 15 March 2017 01:35:50 UTC+5:30, Sathish VJ wrote: > > Ok, I don't know what

[go-nuts] Re: go test error: cannot use matchString as type testing.testDeps in argument to testing.MainStart

2017-03-14 Thread Sathish VJ
Ok, I don't know what exactly went wrong here. But I had sometime previously downloaded a version of go1.8 to test it out. If I explicitly run the tests with that, it runs fine. ~/golang/go1.8/bin/go test Is there any reason why there is a conflict on my system? I don't remember making any

[go-nuts] go test error: cannot use matchString as type testing.testDeps in argument to testing.MainStart

2017-03-14 Thread Sathish VJ
I'm trying to run test on a library that I haven't updated since mid Jan (based on my git log). I know for a fact that I ran tests on the same project during a demo/workshop in february. I try to run the tests now and am seeing the error below: master ± go test # testmain

[go-nuts] Re: [ANN] G3N - Go 3D Game Engine

2017-03-14 Thread leonsal
Hi This group is concerned with general aspects of the Go language. Please generate an issue with your question in our repository: github.com/g3n/engine We will try to answer. Regards. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

[go-nuts] Re: [ANN] G3N - Go 3D Game Engine

2017-03-14 Thread Jamey Cribbs
Is there a proper place where we can ask questions? For example, I am trying to figure out what the monitor resolution is before I create the window, as I have a very high resolution monitor that makes the example windows and text way too small. I figure if I can determine if the monitor

[go-nuts] Re: RSQL, a lighweight clone of Microsoft SQL Server written in Go

2017-03-14 Thread nicolas riesch
To compile from source, follow these instructions: http://rsql.ch/guide/download_page/ -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to

Re: [go-nuts] uint type safety in go

2017-03-14 Thread Eyal Posener
Thanks for the answer. Very interesting. About the run time cost, does go always prefer safety over efficiency? or there is some kind of delicate balance between the two? On Tuesday, March 14, 2017 at 4:12:31 PM UTC+2, Ian Lance Taylor wrote: > > On Tue, Mar 14, 2017 at 6:48 AM, Eyal Posener

[go-nuts] Re: fsnotify: maintainers wanted

2017-03-14 Thread Nathan Youngman
I'm stepping away from the fsnotify project. Maintainers wanted: https://github.com/fsnotify/fsnotify/issues/183#issuecomment-286456045 Good luck, Nathan. On Tuesday, 25 October 2016 12:09:48 UTC-6, Nathan Youngman wrote: > > Hi, > > Fsnotify provides notifications of changes to files and

[go-nuts] Re: RSQL, a lighweight clone of Microsoft SQL Server written in Go

2017-03-14 Thread nicolas riesch
License for the server is GPL. I've just put it right now. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more

[go-nuts] Re: RSQL, a lighweight clone of Microsoft SQL Server written in Go

2017-03-14 Thread nicolas riesch
License for the server is GPL. I've just put it right now. Le lundi 13 mars 2017 21:13:39 UTC+1, nicolas riesch a écrit : > > I have developed RSQL, a *lighweight clone of Microsoft SQL Server*, > which runs on Linux and can execute T-SQL scripts. > > It has been successfully tested with

Re: [go-nuts] uint type safety in go

2017-03-14 Thread Ian Lance Taylor
On Tue, Mar 14, 2017 at 6:48 AM, Eyal Posener wrote: > I was thinking about the type safety of uint in go, and comparing it for a > similar problem. > > If I have this go code: > > var x uint > x-- > > The value of x is then the maximal value of uint, which is probably not what

[go-nuts] uint type safety in go

2017-03-14 Thread Eyal Posener
I was thinking about the type safety of uint in go, and comparing it for a similar problem. If I have this go code: var x uint x-- The value of x is then the maximal value of uint, which is probably not what the gother wanted (I think, is there any particular use cases for that that you know

Re: [go-nuts] Re: Date parsing problem

2017-03-14 Thread Michael Banzon
Thank you - was looking in that direction atm - this is going to take some work (the CSV is user input, it might be anything) ;-) On Tue, Mar 14, 2017 at 2:13 PM Tamás Gulácsi wrote: > unicode/utf16 or golang.org/x/text/encoding. > > -- > You received this message because

Re: [go-nuts] Re: Date parsing problem

2017-03-14 Thread Tamás Gulácsi
unicode/utf16 or golang.org/x/text/encoding. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit

Re: [go-nuts] cross compile windows from linux failed with -H=windowsgui

2017-03-14 Thread Shannon Fang
I found the problem was in my bash script. I added the cross compile var using GOOS=windows, while I should use export GOOS=windows. I think this -H is needed unless there is another way to get rid of the console window under windows :-) Thanks 在 2017年3月14日星期二 UTC+8上午7:43:49,brainman写道: > >

[go-nuts] How to pass value in nested template if possible?

2017-03-14 Thread Simon Ritchie
You are right, the documentation for templates is very scanty. You will find all sorts of useful examples in my scaffolder project https://github.com/goblimey/scaffolder. This doesn't answer your main question, but I see that somebody else has done that. Simon -- You received this message

Re: [go-nuts] Re: Date parsing problem

2017-03-14 Thread Michael Banzon
Thank you - that sent me in the right direction! The data (read from CSV) has a lot of zero bytes - it is UTF-16 LE with BOM (shrugs) - now I just need to find out how to parse these with into "real" Go strings ;-) On Tue, Mar 14, 2017 at 1:26 PM wrote: > May be non-printable

[go-nuts] Re: Date parsing problem

2017-03-14 Thread db047h
May be non-printable garbage at the beginning of "06/11/2014"? When the error occurs, dump the problematic date as a []byte slice and see what it spits out. On Tuesday, March 14, 2017 at 1:13:57 PM UTC+1, mbanzon wrote: > > Hey gophers! > > I'm having some trouble parsing a few dates and I'm

[go-nuts] Date parsing problem

2017-03-14 Thread Michael Banzon
Hey gophers! I'm having some trouble parsing a few dates and I'm thinking I might be missing something obvious. The error I'm getting is: parsing time "06/11/2014" as "02/01/2006": cannot parse "06/11/2014" as "02" The code doing the parsing is deeply inside a much bigger codebase. Running the

Re: [go-nuts] Slice from interface doesn't work as expected

2017-03-14 Thread db047h
Internally, a slice variable is a SliceHeader struct (see https://golang.org/pkg/reflect/#SliceHeader), NOT a pointer to it. Note that len and cap are properties of the SliceHeader struct, NOT of the backing array. So yes, I made a mistake, the x slice header is copied into z at every

Re: [go-nuts] dep: Roadmap for merging into the toolchain

2017-03-14 Thread Jan Mercl
On Tue, Mar 14, 2017 at 12:15 PM Sam Boyer wrote: > I'm don't think that's an accurate summary, at all. The proof is easy ;-) -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group

Re: [go-nuts] dep: Roadmap for merging into the toolchain

2017-03-14 Thread Sam Boyer
I'm don't think that's an accurate summary, at all. On Tuesday, March 14, 2017 at 3:22:22 AM UTC-4, Jan Mercl wrote: > > On Tue, Mar 14, 2017 at 8:01 AM Konstantin Khomoutov < > flat...@users.sourceforge.net > wrote: > > > Please don't miss the monumental heaps of discussions about package >

Re: [go-nuts] Slice from interface doesn't work as expected

2017-03-14 Thread bart2yk
And more, if you assign a slice to another at the beginning will have the same pointer, until one of them will change the capacity. https://play.golang.org/p/BWG5tqayj9 On Monday, March 6, 2017 at 12:12:10 AM UTC+2, db0...@gmail.com wrote: > > This happens only because z is copied every time,

Re: [go-nuts] Slice from interface doesn't work as expected

2017-03-14 Thread bart2yk
example: https://play.golang.org/p/d9KSHScDbL On Monday, March 6, 2017 at 12:12:10 AM UTC+2, db0...@gmail.com wrote: > > This happens only because z is copied every time, but has nothing to do > with interfaces. This exhibits the same behavior without interface{}: >

Re: [go-nuts] Slice from interface doesn't work as expected

2017-03-14 Thread bart2yk
z isn't copied, append will return another pointer only if the capacity will change, but the slice was created from the beginning with enough cap. On Monday, March 6, 2017 at 12:12:10 AM UTC+2, db0...@gmail.com wrote: > > This happens only because z is copied every time, but has nothing to do

[go-nuts] Re: Is there functionality in golang.org/x/crypto/ssh to close a SSH connection server-side after N number of (password) tries?

2017-03-14 Thread ikkini
On Sunday, February 26, 2017 at 6:47:34 AM UTC+1, Tamás Gulácsi wrote: > > Provide a proper PasswordCallback to your server, as in the NewServerConn > example (https://godoc.org/golang.org/x/crypto/ssh#NewServerConn). > > Thats your function, you can program any algorithm you wish. > Thanks

Re: [go-nuts] Re: What happens when appending to a slice exceeds the backing capacity?

2017-03-14 Thread xiiophen
On Monday, 13 March 2017 21:14:27 UTC, Dave Cheney wrote: > > A few clarifications, b does not point to a. a and b are variables of type > []int. The value of each slice's ptr fields point to a backing array of > some capacity. > > If you append to a, this does not change th length or cap

Re: [go-nuts] dep: Roadmap for merging into the toolchain

2017-03-14 Thread Jan Mercl
On Tue, Mar 14, 2017 at 8:01 AM Konstantin Khomoutov < flatw...@users.sourceforge.net> wrote: > Please don't miss the monumental heaps of discussions about package management in Go [1]. Executive summary: Solving the Go's package dependency resolution problem can be either automatic or correct.

Re: [go-nuts] dep: Roadmap for merging into the toolchain

2017-03-14 Thread Konstantin Khomoutov
On Mon, 13 Mar 2017 23:22:54 -0700 (PDT) Albert Tedja wrote: > I was using godeps before and now govendor, and never felt 100% happy > with either one. I have some feedback of how I think the package > management tool should work from the developer perspective, and here >

Re: [go-nuts] dep: Roadmap for merging into the toolchain

2017-03-14 Thread Albert Tedja
I was using godeps before and now govendor, and never felt 100% happy with either one. I have some feedback of how I think the package management tool should work from the developer perspective, and here some features that I think is crucial. 1. Standardize the package file. With govendor,

Re: [go-nuts] RSQL, a lighweight clone of Microsoft SQL Server written in Go

2017-03-14 Thread Konstantin Khomoutov
On Mon, 13 Mar 2017 13:13:39 -0700 (PDT) nicolas riesch wrote: > I have developed RSQL, a *lighweight clone of Microsoft SQL Server*, > which runs on Linux and can execute T-SQL scripts. [...] Do I understand correctly that RSQL does not speak (any version of) MS-TDS