[go-nuts] Re: Implement sub-commands using flag library

2017-12-07 Thread dc0d
Coming late, yet I've written a minimal package 
 (which can be even just copied and paste or 
bundled) that uses only the flag package itself without adding new types, 
just a single function.

On Wednesday, January 1, 2014 at 1:03:07 PM UTC+3:30, Archos wrote:
>
> Another more, flagplus, but with has a simple API:
>
> https://github.com/kless/flagplus
> http://godoc.org/github.com/kless/flagplus
>
> Example of usage: 
> https://github.com/kless/flagplus/blob/master/testing/test.go
>
> El miércoles, 1 de enero de 2014 04:18:36 UTC, Steve Francia escribió:
>>
>> A lot of people are finding Cobra useful.
>>
>> https://github.com/spf13/cobra
>>
>> Inspired by go, go-Commander, gh and subcommand, Cobra improves on these 
>> by providing fully posix compliant flags (including short & long versions), 
>> nesting commands, and the ability to define your own help and usage for any 
>> or all commands.
>>
>> Cobra has an exceptionally clean interface and simple design without 
>> needless constructors or initialization methods.
>>
>> Disclaimer, I'm the author of this project and would love any feedback. 
>>
>

-- 
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 https://groups.google.com/d/optout.


[go-nuts] Re: Calculation of the combinations between an unlimited number of slices

2017-12-07 Thread Fred
Thanks @Jake

Le jeudi 7 décembre 2017 01:01:46 UTC+1, Jake Montgomery a écrit :
>
> On Monday, December 4, 2017 at 2:56:19 PM UTC-5, Fred wrote:
>>
>>
>>  
> Perhaps start with Go Slices: usage and internals 
> , for a more 
> complete understanding of slice pitfalls.
>

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] Re: Implement sub-commands using flag library

2017-12-07 Thread roger peppe
On 7 December 2017 at 09:52, dc0d  wrote:
> Coming late, yet I've written a minimal package (which can be even just
> copied and paste or bundled) that uses only the flag package itself without
> adding new types, just a single function.

I like the minimalism, but how are you supposed to know which subcommand
has been chosen?

-- 
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 https://groups.google.com/d/optout.


[go-nuts] Newbie cgo question

2017-12-07 Thread asaaveri
All:

I am working on a pilot go/cgo project for a database driver.  For one of 
my C functions called by go, I chose a generic, unfortunate name 
connect().  My program  kept dumping core on Linux.  I did some tracing and 
found out that my function connect() was being called twice even though I 
called it just once.  I renamed the function as myconnect() and the problem 
went away.  Here is an nm output after the fact:

0277 T _cgo_c208fc38ae96_Cfunc_myconnect
0634 T myconnect

Is this expected?  Is there a general pattern to protect against this?

With regards,

-- 
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 https://groups.google.com/d/optout.


[go-nuts] Re: [ANN] gometalinter v2.0.0 released - much faster linting

2017-12-07 Thread Pierre Durand
Thank you! :)

Le mardi 5 décembre 2017 08:10:50 UTC+1, Alec Thomas a écrit :
>
> Hello,
>
> Through the efforts of many contributors, and in particular those of 
> Daniel Nephin, v2.0.0 has been released. You can grab it here:
>
> https://github.com/alecthomas/gometalinter/releases/tag/v2.0.0
>
> The biggest change since v1.x is that linting is now MUCH more efficient, 
> thanks to the changes by Daniel. Instead of invoking each linter for every 
> directory, linters are invoked the minimum number of times necessary by 
> passing as many directories, packages or files as they will accept in a 
> single invocation.
>
> The configuration format has also changed, but should be mostly backwards 
> compatible.
>
> Another major change is that from now on we will be releasing binary 
> packages. This also means that: gometalinter's management of linter 
> installation will soon be deprecated, and eventually removed, and that 
> gopkg.in will no longer be used.
>
> Going forward we have several interesting things planned for gometalinter:
>
> 1. Support for in-process invocation of linters via an interface + 
> adapters. See https://github.com/alecthomas/gometalinter/issues/380. This 
> should make linting even more efficient, as packages will only need to be 
> parsed/compiled once, and the FileSet (etc.) can be reused.
> 2. Configuration handling will be rewritten/rethought. This will encompass 
> automatic .gometalinterrc loading, among other things.
> 3. Lots of internal refactoring to clean up the codebase.
>
> As always, if you encounter any problems please create a new issue.
>
> Regards,
> Alec
>

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] Re: Implement sub-commands using flag library

2017-12-07 Thread dc0d
The way it is implemented currently, it supports multiple commands. And it 
can be decided by checking the flags against their default values.

Maybe it should return a []string. Any specific suggestions?

On Thursday, December 7, 2017 at 7:13:57 PM UTC+3:30, rog wrote:
>
> On 7 December 2017 at 09:52, dc0d > 
> wrote: 
> > Coming late, yet I've written a minimal package (which can be even just 
> > copied and paste or bundled) that uses only the flag package itself 
> without 
> > adding new types, just a single function. 
>
> I like the minimalism, but how are you supposed to know which subcommand 
> has been chosen? 
>

-- 
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 https://groups.google.com/d/optout.


[go-nuts] Re: Bcrypt isn't comparing stored password hash properly

2017-12-07 Thread Gabriel Simmer
So after much looking, I've concluded it's not an issue with the database 
encoding. What's odd is if I manually add the hash to the database it 
functions fine.

On Tuesday, December 5, 2017 at 11:39:38 AM UTC-8, Gabriel Simmer wrote:
>
> Hey Gophers,
>
> I have a bit of a headscratcher for you guys today, hoping someone will be 
> able to help me track down where I've gone wrong. I have an SQLite3 
> database with user login info, including username, hashed password w/ 
> bcrypt, and so on. I also have a "setup" method that is triggered on the 
> first run of the application, which includes creating the database, setting 
> an admin password and fetching assets. There's one hitch - the hashed 
> password doesn't seem to be either:
>
>  - Stored properly
>  - Hashed properly
>  - Compared properly
>
> I've done some extensive testing and it appears bcrypt *is* hashing the 
> password, and I can compare it successfully right after, and before I put 
> it into the database. All good. However when I pull the hash from the 
> database later (on user login), bcrypt doesn't see the hash and the 
> password as equal and errors out. 
>
> Here is the GitHub repository's branch 
> , if you want to fully test 
> the application, but the relevant files are setup.go 
>  and 
> router/router.go 
> . 
> I've left in some debugging checks, and will happily answer any questions I 
> haven't clarified. 
>

-- 
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 https://groups.google.com/d/optout.


[go-nuts] Re: [urgent] need aguments to justify use of Go for a scientific application

2017-12-07 Thread 'Eric Johnson' via golang-nuts
One last bit of perspective here, which may be relevant to your project?

I've found that Go has the lowest cognitive load "switching" load. I have a 
job that mostly doesn't involve coding. When I get to code, I have a 
limited window in which I can jump in and make changes. Amongst the 
languages I've worked with, which includes Ruby, Python, Java, Bash, and 
C++, Go is the clear winner. By which I mean, the time it takes me to 
switch back to writing Go code and start making effective changes is 
shorter than it is with any other language I've mentioned.

With languages like Python and Ruby, I've found switching costs to be very 
high. The lack of compile time type-information means it is difficult to 
determine what the "type" of a parameter to a function, or the result of a 
method might be. You have to go and look at other chunks of code to figure 
that out, and that can be costly. Also, the use of exceptions means that 
there are always invisible control flows that are hard to remember / see 
when switching back to code.

With Java, the class hierarchy, the distinctions between public, private, 
protected, and package level accessibility all add complexity that some 
part of my brain needs to recall / rediscover before I can be confident of 
the correctness of a change.

C++ is even more complex than Java. Mental switching costs are even higher.

If your project is one that involves only short windows of opportunity to 
work on code, while mostly focusing on other tasks - like analyzing your 
data - then Go might be an enormous benefit. If your project is structured 
more like an ordinary software development project, with focused developers 
who can work on the project for four to seven hours a day, this aspect of 
Go won't matter.

Eric.


On Wednesday, December 6, 2017 at 1:56:01 AM UTC-8, Christophe Meessen 
wrote:
>
> Hello, 
>
> I'm a computer scientist in charge of developing an image processing 
> pipeline for telescope images. 
> It will also have a web server and DB connection.
>
> The project is going through reviews by external experts, and the problem 
> I'm facing is that my proposal to use Go is about to be rejected. 
>
> The main opposing arguments are 
> - everybody uses python in astrophysics
> - it is very easy to find someone who knows python
> - risk that I, sole Go programmer, might become unavailable
>
> I would have the same arguments if I was project leader and unfamiliar 
> with Go. 
>
> The counter arguments I found so far are that
> - Go is simpler and safer than Python
> - I learned Go in a week-end
>
> The problem is that they don't convince people who don't know Go, are not 
> experienced software developers, and don't want to do the due diligence. 
> It's the usual inertia to change.  
>
> What other arguments could I use ?
>
> Do you know other significant scientific experiments that have adopted Go 
> ? 
>
>
>
> I have found this github project. 
> https://github.com/indigo-astronomy/indigo
> INDI is a well known Python Observatory Control System. 
> INDIGO is its translation into Go. 
>
> I have also found SciPipe https://github.com/scipipe.
> It is a Go pipeline framework used in scientific applications. 
>
>
>

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] Newbie cgo question

2017-12-07 Thread Ian Lance Taylor
On Thu, Dec 7, 2017 at 4:53 AM,   wrote:
>
> I am working on a pilot go/cgo project for a database driver.  For one of my
> C functions called by go, I chose a generic, unfortunate name connect().  My
> program  kept dumping core on Linux.  I did some tracing and found out that
> my function connect() was being called twice even though I called it just
> once.  I renamed the function as myconnect() and the problem went away.
> Here is an nm output after the fact:
>
> 0277 T _cgo_c208fc38ae96_Cfunc_myconnect
> 0634 T myconnect
>
> Is this expected?  Is there a general pattern to protect against this?

This is a general problem with C, that Go avoids by using packages and
C++ avoids by using namespaces.  C has a single flat namespace for all
functions, and if you accidentally reuse an existing function name
your program will behave strangely.  The general pattern to protect
against this is to use static functions whenever possible, and to use
a unique prefix for all globally visible functions.

Ian

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] Re: Implement sub-commands using flag library

2017-12-07 Thread roger peppe
On 7 December 2017 at 17:20, dc0d  wrote:
> The way it is implemented currently, it supports multiple commands. And it
> can be decided by checking the flags against their default values.

That won't work if you don't pass any flags!

> Maybe it should return a []string. Any specific suggestions?

I'd suggest that only one command can be specified at any one time
(all the command line apps that I know work like this).

As far as I can see from a brief glance, your package doesn't allow
any non-flag arguments to be passed to a subcommand.

How about making Parse return the name of the selected subcommand (or
the empty string if none is specified) ?

BTW as of Go 1.10, you'll be able to avoid the dubious reflect hack to
get the name from the FlagSet.

>
> On Thursday, December 7, 2017 at 7:13:57 PM UTC+3:30, rog wrote:
>>
>> On 7 December 2017 at 09:52, dc0d  wrote:
>> > Coming late, yet I've written a minimal package (which can be even just
>> > copied and paste or bundled) that uses only the flag package itself
>> > without
>> > adding new types, just a single function.
>>
>> I like the minimalism, but how are you supposed to know which subcommand
>> has been chosen?
>
> --
> 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 https://groups.google.com/d/optout.

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] Re: Implement sub-commands using flag library

2017-12-07 Thread dc0d

>
> > That won't work if you don't pass any flags! 

Indeed. The best approach is to check against default values.

>
> I'd suggest that only one command can be specified at any one time (all 
the command line apps that I know work like this). 

True. I'll fix that.

> As far as I can see from a brief glance, your package doesn't allow any 
non-flag arguments to be passed to a subcommand. 

They are just the builtin FlagSet, so the Args() function returns the 
non-flag args.

>
> How about making Parse return the name of the selected subcommand (or the 
empty string if none is specified) ? 

Seems the only logical option! Thanks!

> BTW as of Go 1.10, you'll be able to avoid the dubious reflect hack to 
get the name from the FlagSet. 

Looking forward to that!

-- 
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 https://groups.google.com/d/optout.


Re: [go-nuts] Re: Implement sub-commands using flag library

2017-12-07 Thread dc0d
Thanks again Roger. I've applied those suggestions.

-- 
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 https://groups.google.com/d/optout.


[go-nuts] package for concurrent os.File operations

2017-12-07 Thread Vasiliy Tolstov
I have []*os.File that need to be Write/Close/Sync/Seek concurrent
with proper return values (so if one Write return error i need to
catch it ad return to upper layer. In case Seek  i need to check that
all Seeks returns equal values without errors. Ideally that []*os.File
is wrapped to interface that can be read/write/close/seek/sync...

Does somebody already knows such package or knows how to best write it ?


-- 
Vasiliy Tolstov,
e-mail: v.tols...@selfip.ru

-- 
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 https://groups.google.com/d/optout.


[go-nuts] Re: Bcrypt isn't comparing stored password hash properly

2017-12-07 Thread matthewjuran
Are you sure for rows.Next() is returning true in router.go? Usually there 
is a call to rows.Error() after the iteration too.

Matt

On Thursday, December 7, 2017 at 11:33:53 AM UTC-6, Gabriel Simmer wrote:
>
> So after much looking, I've concluded it's not an issue with the database 
> encoding. What's odd is if I manually add the hash to the database it 
> functions fine.
>
> On Tuesday, December 5, 2017 at 11:39:38 AM UTC-8, Gabriel Simmer wrote:
>>
>> Hey Gophers,
>>
>> I have a bit of a headscratcher for you guys today, hoping someone will 
>> be able to help me track down where I've gone wrong. I have an SQLite3 
>> database with user login info, including username, hashed password w/ 
>> bcrypt, and so on. I also have a "setup" method that is triggered on the 
>> first run of the application, which includes creating the database, setting 
>> an admin password and fetching assets. There's one hitch - the hashed 
>> password doesn't seem to be either:
>>
>>  - Stored properly
>>  - Hashed properly
>>  - Compared properly
>>
>> I've done some extensive testing and it appears bcrypt *is* hashing the 
>> password, and I can compare it successfully right after, and before I put 
>> it into the database. All good. However when I pull the hash from the 
>> database later (on user login), bcrypt doesn't see the hash and the 
>> password as equal and errors out. 
>>
>> Here is the GitHub repository's branch 
>> , if you want to fully test 
>> the application, but the relevant files are setup.go 
>>  and 
>> router/router.go 
>> . 
>> I've left in some debugging checks, and will happily answer any questions I 
>> haven't clarified. 
>>
>

-- 
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 https://groups.google.com/d/optout.


[go-nuts] Go 1.10 Beta 1 is released

2017-12-07 Thread Andrew Bonventre
Hello gophers,

We have just released go1.10beta1, a beta version of Go 1.10.
It is cut from the master branch at the revision tagged go1.10beta1.

There are no known problems or regressions.
Please try running production load tests and your unit tests with the new
version.
Your help testing these pre-release versions is invaluable.

Report any problems using the issue tracker:
https://golang.org/issue/new

If you have Go installed already, the easiest way to try go1.10beta1
is by using this tool:
https://godoc.org/golang.org/x/build/version/go1.10beta1

You can download binary and source distributions from the usual place:
https://golang.org/dl/#go1.10beta1

To find out what has changed in Go 1.10, read the draft release notes:
https://beta.golang.org/doc/go1.10

Documentation for Go 1.10 is available at:
https://beta.golang.org/

Cheers,
Andy

-- 
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 https://groups.google.com/d/optout.


[go-nuts] Re: understanding memory profile

2017-12-07 Thread Sangjin Lee
It is actually with the latest (1.9.2). I'll file an issue.

Thanks.

On Tuesday, December 5, 2017 at 1:51:07 PM UTC-8, Dave Cheney wrote:
>
> Can you please check if this is happening with the current version of Go 
> and if so raise a bug, https://golang.org/issue/new. 
>
> Thanks 
>

-- 
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 https://groups.google.com/d/optout.