Re: [go-nuts] Writing safe CGO calls and callbacks and how that affects system threads

2017-02-13 Thread Luka Napotnik
Ok, thanks for the clarification.

On Tue, Feb 14, 2017 at 12:53 AM Ian Lance Taylor  wrote:

> On Mon, Feb 13, 2017 at 1:14 PM,   wrote:
> > On Monday, February 13, 2017 at 7:02:22 AM UTC+1, Luka Napotnik wrote:
> >>
> >> I forgot to mention that the main goroutine in the test program is
> locked
> >> to a thread as I call runtime.LockOSThread() in init()
> >
> >
> > The Go Spec says "Package initialization—variable initialization and the
> > invocation of init functions—happens in a single goroutine, sequentially,
> > one package at a time. An init function may launch other goroutines,
> which
> > can run concurrently with the initialization code.". The way I understand
> > it, code in init() is not guaranteed to run in the same goroutine as
> main(),
> > so you might be better of calling LockOSThread() from main() (or from
> > whatever goroutine will do the GTK calls).
>
> I think you're right that the spec does not guarantee that the same
> goroutine runs init functions and the main function.  I'll just note
> that in practice it is the same goroutine, for all the implementations
> I know of.
>
> Ian
>
-- 
Greets,
Luka Napotnik

-- 
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] Looking for free, part-time, remote internship.

2017-02-13 Thread Malhar Vora
Hi Bakul,

Thanks for very good explanation.

I agree with your idea of creating my own application using Go. Also that
is totally correct that already created projects mostly have architecture
in place and I need to work according to their practices.

Regarding coding skills , I am carrying 3 years of experience in Python and
already working on improving my coding skill by applying patterns,
principles and best practices.

Regarding open source contribution Jonathan pointed me to a project that he
and some other developers contribute to. The project itself is around my
area of interest like containers and also Jonathan has promised me to guide
me. So now I have a great project and great guide. The next step is to
apply my best to contribute to project.

Keep in touch.

Thanks,



Regds,
*Malhar Vora*
http://about.me/malhar.vora


On Tue, Feb 14, 2017 at 9:20 AM, Bakul Shah  wrote:

> Here’s a somewhat different POV. Hope it helps.
>
> If you decide to work on an existing project, often times as a newbie
> you’ll be asked to fix bugs or add a small feature, which may not always
> the most exciting thing to do + you may have to bootstrap on the code and
> learn a lot of other stuff which isn’t directly relevant to your goal of
> learning a new language. Plus the program architecture is already in place,
> many of the major decisions have already been made and your code has to fit
> within the existing framework. On the positive side, you will likely learn
> good programming habits, may be get access to a mentor, you’ll be
> contributing to something useful, you’ll learn how to work in a team, get
> familiar with code reviews, unit tests etc.
>
> Another option is to code up from scratch something you are interested in.
> If you are really interested in the subject, you’ll more likely stick with
> coding up your solution. Writing a whole program can be very satisfying. It
> can also be scary and overwhelming but the trick is pick something that not
> too complicated and not too trivial. You’ll have to make all the decisions,
> tiny ones as well as major ones, including the architecture of your
> program, whether to write your own code or use an existing go package, look
> at algorithm choices, get a better feel for how the program may be used
> etc. etc. If you build it incrementally and are not afraid to restructure
> or throw out code as needed, you will learn a lot and have lots of fun.
>
> Both options are useful and you’ll learn different things so if you can,
> do both!
>
> Go is actually very good for the second option. You can bring up minimal
> working code very quickly (in hours even if you start from scratch —
> provided you are the type who is always itching write code and not the type
> who has to know everything before writing a single line of code). Then you
> can add one feature at a time, write unit tests for it, and always have a
> working program. Having a code, compile, run, test, debug cycle that can be
> as short as minutes can be very motivating. Then most of your time is not
> spent on tinkering with your program but on thinking about the problem you
> are solving.
>
> I guess what I am saying is that instead of focusing on "learning Go”,
> focus on learning good programming skills while "using Go" as a medium. As
> a famous scientist once said, the best way to have a great idea is to have
> lots of ideas! The same is true for programming so write lots of code! All
> the great programmers I know (of) are/were prolific programmers.
>
> On Feb 13, 2017, at 12:35 AM, Malhar Vora  wrote:
>
> Hi Jacob,
>
> Thanks for reply. I'll surely check links you have provided.
>
> I agree with your suggestion regarding famous hot repos trending on
> Github. I'll check them too.
>
>
> Thanks,
>
>
> Regds,
> *Malhar Vora*
> http://about.me/malhar.vora
>
>
> On Mon, Feb 13, 2017 at 12:23 PM, Jakob Borg  wrote:
>
>> You can probably assume by default that any open source project out there
>> with open issues welcomes your help. :)
>>
>> On GitHub, you can list the most starred repos. These are projects that
>> have been around for a long time and probably are fairly mature in
>> welcoming new contributors. Definitely browse past the first page of
>> results. I see Syncthing is still on there and we certainly welcome you. ;)
>> The ones not obviously tied to a corporate backer may be more in need -
>> although if you're looking for a position at one of the companies in
>> question this could maybe be an inroad, I don't know.
>>
>> https://github.com/search?l=go&q=stars%3A%3E1&s=stars&type=
>> Repositories
>>
>> There are also the currently trending ones, although these may in some
>> sense be the ones least in need of additional help since they are
>> apparently getting lots of attention now anyway. But they are also hot (and
>> cool) and probably get lots of bug reports if they are just coming into
>> fame.
>>
>> https://github.com/trending/go?since=monthly
>>
>> Try to find something tha

Re: [go-nuts] Looking for free, part-time, remote internship.

2017-02-13 Thread Bakul Shah
Here’s a somewhat different POV. Hope it helps.

If you decide to work on an existing project, often times as a newbie you’ll be 
asked to fix bugs or add a small feature, which may not always the most 
exciting thing to do + you may have to bootstrap on the code and learn a lot of 
other stuff which isn’t directly relevant to your goal of learning a new 
language. Plus the program architecture is already in place, many of the major 
decisions have already been made and your code has to fit within the existing 
framework. On the positive side, you will likely learn good programming habits, 
may be get access to a mentor, you’ll be contributing to something useful, 
you’ll learn how to work in a team, get familiar with code reviews, unit tests 
etc.

Another option is to code up from scratch something you are interested in. If 
you are really interested in the subject, you’ll more likely stick with coding 
up your solution. Writing a whole program can be very satisfying. It can also 
be scary and overwhelming but the trick is pick something that not too 
complicated and not too trivial. You’ll have to make all the decisions, tiny 
ones as well as major ones, including the architecture of your program, whether 
to write your own code or use an existing go package, look at algorithm 
choices, get a better feel for how the program may be used etc. etc. If you 
build it incrementally and are not afraid to restructure or throw out code as 
needed, you will learn a lot and have lots of fun.

Both options are useful and you’ll learn different things so if you can, do 
both!

Go is actually very good for the second option. You can bring up minimal 
working code very quickly (in hours even if you start from scratch — provided 
you are the type who is always itching write code and not the type who has to 
know everything before writing a single line of code). Then you can add one 
feature at a time, write unit tests for it, and always have a working program. 
Having a code, compile, run, test, debug cycle that can be as short as minutes 
can be very motivating. Then most of your time is not spent on tinkering with 
your program but on thinking about the problem you are solving.

I guess what I am saying is that instead of focusing on "learning Go”, focus on 
learning good programming skills while "using Go" as a medium. As a famous 
scientist once said, the best way to have a great idea is to have lots of 
ideas! The same is true for programming so write lots of code! All the great 
programmers I know (of) are/were prolific programmers.

> On Feb 13, 2017, at 12:35 AM, Malhar Vora  wrote:
> 
> Hi Jacob,
> 
> Thanks for reply. I'll surely check links you have provided.
> 
> I agree with your suggestion regarding famous hot repos trending on Github. 
> I'll check them too.
> 
> 
> Thanks,
> 
> 
> Regds,
> Malhar Vora
> http://about.me/malhar.vora 
> 
> 
> On Mon, Feb 13, 2017 at 12:23 PM, Jakob Borg  > wrote:
> You can probably assume by default that any open source project out there 
> with open issues welcomes your help. :)
> 
> On GitHub, you can list the most starred repos. These are projects that have 
> been around for a long time and probably are fairly mature in welcoming new 
> contributors. Definitely browse past the first page of results. I see 
> Syncthing is still on there and we certainly welcome you. ;) The ones not 
> obviously tied to a corporate backer may be more in need - although if you're 
> looking for a position at one of the companies in question this could maybe 
> be an inroad, I don't know.
> 
> 
> https://github.com/search?l=go&q=stars%3A%3E1&s=stars&type=Repositories 
> 
> 
> There are also the currently trending ones, although these may in some sense 
> be the ones least in need of additional help since they are apparently 
> getting lots of attention now anyway. But they are also hot (and cool) and 
> probably get lots of bug reports if they are just coming into fame.
> 
> https://github.com/trending/go?since=monthly 
> 
> 
> Try to find something that you use yourself, or that uses a technology or 
> solves a problem you find interesting.
> 
> //jb
> 
> 
> > On 13 Feb 2017, at 03:09, Néstor  > > wrote:
> >
> > Hi,
> >
> > I like e in San Diego, California and I am in the same boat as Malhar, 
> > looking for a chance in the Golang world.
> >
> > Jonathan, how do you find out about open source projects  in Golang that 
> > need help?
> >
> > Thanks,
> >
> > Néstor
> >
> >
> > On Feb 12, 2017 5:35 PM, "Jonathan Yu"  > > wrote:
> > Have you considered contributing to an open source project of interest to 
> > you?
> >
> >
> > On Sun, Feb 12, 2017, 10:27 Malhar Vora  > > wrote:
> >
> >
> >
> >  Hi Everyone,
> >
> > 

Re: [go-nuts] Re: Struggling with working directory

2017-02-13 Thread Diego Medina
> Not sure why its being difficult.

knowing why I needed a GOPATH and what it was used for was probably the
main issue I had when I started with Go too, some 3+ years ago, we'll help
you get through it. Now, if you go back to the original instructions,
https://golang.org/doc/install#install

you then just need to decide where **your** code and any code you import
into your proejct(s) will be based off. Unlike many other languages where
you can just start a project wherever you feel like, all Go projects start
off from $GOPATH , but the regular install doesn't set this path for you
(it will in 1.8). But don't worry, all it means is do this:

$ export GOPATH=/home//go

(you can add that to ~/.bash_profile so you don't have to do it after every
reboot of your computer)

So, once you have your GOPATH environment variable ready, you can create
the structure for your new project:

$  mkdir $GOPATH/src/github.com/mortalcatalyst/xml

$ cd $GOPATH/src/github.com/mortalcatalyst/xml
$ write some awesome code now in here
$ go install # note that you do not need to specify the path to your
project, because you are already inside your project root folder

and at this point you are ready to use your new cool app :)

If any of these instructions don't help or give you an error, post back
what you got.

Thanks

Diego






On Mon, Feb 13, 2017 at 5:07 PM, Sayth Renshaw 
wrote:

> That's the one i used first but got errors that it couldn't find GOPATH
> even though i installed it to the suggested default location.
>
> So when that didn't work i delete the go directory and the details from
> .profile and then followed ://www.digitalocean.com/
> community/tutorials/how-to-install-go-1-6-on-ubuntu-16-04.
>
> Not sure why its being difficult.
>
> Cheers
>
> Sayth
>
> On Mon, 13 Feb 2017, 11:41 PM Diego Medina  wrote:
>
>> Can you include the link to the guide you followed to install Go?
>>
>> I always follow
>> https://golang.org/doc/install#install
>>
>> which is, after downloading from the link on that page,:
>>
>> tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
>>
>> and then adding:
>>
>> /usr/local/go/bin to the PATH
>>
>>
>> And I have never had to set GOBIN
>>
>> Thanks
>>
>> Diego
>>
>>
>>
>> On Mon, Feb 13, 2017 at 5:39 AM, Sayth Renshaw 
>> wrote:
>>
>>
>>
>> On Sunday, 12 February 2017 04:16:15 UTC+11, Diego Medina wrote:
>>
>> Hi,
>>
>> you were very close, instead of
>>
>> go install github.com/mortalcatalyst/xml/xml.go
>>
>> do
>>
>> go install github.com/mortalcatalyst/xml
>>
>>
>> In go, you don't install the particular file, you install the program as
>> a whole (which in many cases, it involves more than one file)
>>
>> And as a side note, normally you would
>>
>> $ cd $GOPATH/src/github.com/mortalcatalyst/xml
>> $ go install
>>
>>
>> so you don't have to specify the whole path to the project every time.
>>
>> Hope that helps
>>
>> P.S. as you work with Go more and more, you'll want to add these lines to
>> ~/.bash_profile:
>>
>> CDPATH=.:$GOPATH/src/github.com:$GOPATH/src/bitbucket.org #you may add
>> more domains here if you host your proejct(s) somewhere else
>> export CDPATH
>>
>> that let's you, form anywhere in your terminal, to type:
>>
>> $ cd mor
>>
>> Then press tab and the terminal will autocomplete mortalcatalyst
>>
>> P.S. source of the tip https://twitter.com/rob_
>> pike/status/467367507305574400
>>
>> Diego
>>
>>
>>
>>
>>
>>
>> Hi
>>
>> I now seem to have hit another problem
>>
>> sayth@sayth-E6410 ~/work/src/github.com/mortalcatalyst/xml $ go install
>> github.com/mortalcatalyst/xml
>> cannot install, GOBIN must be an absolute path
>>
>> An absolute path? I think somehow those directions have created a bad
>> install.
>>
>> Is there a way I can reset to defaults and is there a better install
>> method so that I can get a clean and working environment. Keep running into
>> errors and cannot execute code.
>>
>> Cheers
>>
>> Sayth
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "golang-nuts" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/
>> topic/golang-nuts/YE0w1Cbb1Ac/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> golang-nuts+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>>
>> --
>> Diego Medina
>> Lift/Scala Consultant
>> di...@fmpwizard.com
>> https://blog.fmpwizard.com/
>>
>


-- 
Diego Medina
Lift/Scala Consultant
di...@fmpwizard.com
https://blog.fmpwizard.com/

-- 
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] xattrib on symlinks and holes in syscall support

2017-02-13 Thread 'simon place' via golang-nuts
i have been tidying up some xattrib (extended file attribute) code, and had 
what i thought was a cool idea.

that idea used xattribs on symlinks.

but when i tried this i found that syscall.Getxattr uses the sys call for 
following syslinks, (it wraps SYS_GETXATTR) and that the corresponding 
syscall for not following symlinks, (SYS_LGETXATTR) is not wrapped, 
although an unused symbol for it is there.

since this means there is no way to access xattribs on symlinks, whereas 
wrapping the other symbol would have allowed both, i wonder why this 
decision? 

basically i cant see why they aren’t all wrapped, isn't this an automated 
process?

-- 
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] Writing safe CGO calls and callbacks and how that affects system threads

2017-02-13 Thread Ian Lance Taylor
On Mon, Feb 13, 2017 at 1:14 PM,   wrote:
> On Monday, February 13, 2017 at 7:02:22 AM UTC+1, Luka Napotnik wrote:
>>
>> I forgot to mention that the main goroutine in the test program is locked
>> to a thread as I call runtime.LockOSThread() in init()
>
>
> The Go Spec says "Package initialization—variable initialization and the
> invocation of init functions—happens in a single goroutine, sequentially,
> one package at a time. An init function may launch other goroutines, which
> can run concurrently with the initialization code.". The way I understand
> it, code in init() is not guaranteed to run in the same goroutine as main(),
> so you might be better of calling LockOSThread() from main() (or from
> whatever goroutine will do the GTK calls).

I think you're right that the spec does not guarantee that the same
goroutine runs init functions and the main function.  I'll just note
that in practice it is the same goroutine, for all the implementations
I know of.

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] efficiency of string <-> []byte conversion

2017-02-13 Thread Ian Lance Taylor
On Mon, Feb 13, 2017 at 12:31 PM, Alex Flint  wrote:
>
> As of go1.8, do conversions between strings and byte slices always generate
> a copy?

Usually but not absolutely always.

The gc compiler has an optimization for map lookups.  For a
map[string]T, when s is a []byte, m[string(s)] will not make a copy.

I'm not aware of any other similar slice <-> string optimization in
the gc compiler.  There could be some that I don't know about.

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] Writing safe CGO calls and callbacks and how that affects system threads

2017-02-13 Thread db047h
On Monday, February 13, 2017 at 7:02:22 AM UTC+1, Luka Napotnik wrote:
>
> I forgot to mention that the main goroutine in the test program is locked 
> to a thread as I call runtime.LockOSThread() in init()


The Go Spec  says 
"Package initialization—variable initialization and the invocation of init 
functions—happens in a single goroutine, sequentially, one package at a 
time. An init function may launch other goroutines, which can run 
concurrently with the initialization code.". The way I understand it, code 
in init() is not guaranteed to run in the same goroutine as main(), so you 
might be better of calling LockOSThread() from main() (or from whatever 
goroutine will do the GTK calls).

-- 
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: Struggling with working directory

2017-02-13 Thread Dave Cheney
Those instructions are wrong, I've written to the author and asked them to 
remove the incorrect information.

Please follow the installation instructions on the golang.org website, they 
are well tested and known to work well. https://golang.org/doc/install

On Tuesday, 14 February 2017 09:07:54 UTC+11, Sayth Renshaw wrote:
>
> That's the one i used first but got errors that it couldn't find GOPATH 
> even though i installed it to the suggested default location. 
>
> So when that didn't work i delete the go directory and the details from 
> .profile and then followed ://
> www.digitalocean.com/community/tutorials/how-to-install-go-1-6-on-ubuntu-16-04
> .
>
> Not sure why its being difficult. 
>
> Cheers
>
> Sayth 
>
> On Mon, 13 Feb 2017, 11:41 PM Diego Medina  > wrote:
>
>> Can you include the link to the guide you followed to install Go?
>>
>> I always follow
>> https://golang.org/doc/install#install
>>
>> which is, after downloading from the link on that page,:
>>
>> tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
>>
>> and then adding:
>>
>> /usr/local/go/bin to the PATH 
>>
>>
>> And I have never had to set GOBIN
>>
>> Thanks
>>
>> Diego
>>
>>
>>
>> On Mon, Feb 13, 2017 at 5:39 AM, Sayth Renshaw > > wrote:
>>
>>>
>>>
>>> On Sunday, 12 February 2017 04:16:15 UTC+11, Diego Medina wrote:

 Hi,

 you were very close, instead of

 go install github.com/mortalcatalyst/xml/xml.go

 do

 go install github.com/mortalcatalyst/xml


 In go, you don't install the particular file, you install the program 
 as a whole (which in many cases, it involves more than one file)

 And as a side note, normally you would 

 $ cd $GOPATH/src/github.com/mortalcatalyst/xml
 $ go install


 so you don't have to specify the whole path to the project every time.

 Hope that helps

 P.S. as you work with Go more and more, you'll want to add these lines 
 to ~/.bash_profile:

 CDPATH=.:$GOPATH/src/github.com:$GOPATH/src/bitbucket.org #you may add 
 more domains here if you host your proejct(s) somewhere else
 export CDPATH

 that let's you, form anywhere in your terminal, to type:

 $ cd mor 

 Then press tab and the terminal will autocomplete mortalcatalyst

 P.S. source of the tip 
 https://twitter.com/rob_pike/status/467367507305574400

 Diego






>>> Hi
>>>
>>> I now seem to have hit another problem  
>>>
>>> sayth@sayth-E6410 ~/work/src/github.com/mortalcatalyst/xml $ go install 
>>> github.com/mortalcatalyst/xml
>>> cannot install, GOBIN must be an absolute path
>>>
>>> An absolute path? I think somehow those directions have created a bad 
>>> install.
>>>
>>> Is there a way I can reset to defaults and is there a better install 
>>> method so that I can get a clean and working environment. Keep running into 
>>> errors and cannot execute code.
>>>
>>> Cheers
>>>
>>> Sayth
>>>
>>> -- 
>>> You received this message because you are subscribed to a topic in the 
>>> Google Groups "golang-nuts" group.
>>> To unsubscribe from this topic, visit 
>>> https://groups.google.com/d/topic/golang-nuts/YE0w1Cbb1Ac/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to 
>>> golang-nuts...@googlegroups.com .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> -- 
>> Diego Medina
>> Lift/Scala Consultant
>> di...@fmpwizard.com 
>> https://blog.fmpwizard.com/
>>
>

-- 
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: efficiency of string <-> []byte conversion

2017-02-13 Thread Val
Right, most approaches don't cover all the cases (which would be 
impossible, but we can still try to tend to).
In my porous memories, some cases were not exactly about immutability, 
rather about escape analysis :
"If I just built []byte x, and I return string(x), and x doesn't escape, 
then the conversion shoud be free of charge"
and symmetrically though less useful :
"If I just built string y, and I return []byte(y), and y doesn't escape, 
then the conversion shoud be free of charge"

But I don't have skills to answer these kind of compiler-related question, 
so I would be more comfortable letting others speak.
Cheers

On Monday, February 13, 2017 at 11:30:21 PM UTC+1, Alex Flint wrote:
>
> Thanks Val. I actually did a search before posting this and turned up many 
> of those same links, but it seems like they're all just reasoning from the 
> immutability of strings, which I don't think is quite sufficient to answer 
> the question in all cases. Anyway, thanks for your help and I think for now 
> I'll work on the assumption that string/byteslice conversions do always 
> copy.
>
> On Mon, Feb 13, 2017 at 2:22 PM Val > 
> wrote:
>
>> Hello Alex,
>> good point. I remember this has indeed come up in discussions in this 
>> forum.
>>
>> Searching "byte slice string copy" gave (among others) [1] [2] [3] [4] 
>> [5] [6] [7]. All of these look related to the suggested optimization "don't 
>> allocate© for a []byte to string, or string to []byte, conversion, 
>> under certain circumstances".
>> Cheers
>>  Val
>>
>> [1] 
>> https://groups.google.com/forum/#!searchin/golang-nuts/byte$20slice$20string$20copy|sort:relevance/golang-nuts/m46jaS6bgZg/R5hSOPFz5m0J
>> [2] 
>> https://groups.google.com/forum/#!searchin/golang-nuts/byte$20slice$20string$20copy|sort:relevance/golang-nuts/CwoKDOhv6vw/sf35VZOZDQAJ
>> [3] 
>> https://groups.google.com/forum/#!searchin/golang-nuts/byte$20slice$20string$20copy|sort:relevance/golang-nuts/ENgbUzYvCuU/gWa8V8wGAwAJ
>> [4] 
>> https://groups.google.com/forum/#!searchin/golang-nuts/byte$20slice$20string$20copy|sort:relevance/golang-nuts/ajXzEM6lqJI/vRsqXxizBAAJ
>> [5] 
>> https://groups.google.com/forum/#!searchin/golang-nuts/byte$20slice$20string$20copy|sort:relevance/golang-nuts/f2cX-BIJsqY/bzK77xpU8PMJ
>> [6] 
>> https://groups.google.com/forum/#!searchin/golang-nuts/byte$20slice$20string$20copy|sort:relevance/golang-nuts/IfILC-wllaI/U8v88T3aBgAJ
>> [7] 
>> https://groups.google.com/forum/#!searchin/golang-nuts/byte$20slice$20string$20copy|sort:relevance/golang-nuts/fXmG83gZOJg/eixtKSQiNysJ
>>
>>
>> On Monday, February 13, 2017 at 9:31:06 PM UTC+1, Alex Flint wrote:
>>>
>>> As of go1.8, do conversions between strings and byte slices always 
>>> generate a copy?
>>>
>>> I understand the immutability guarantees in the language spec, but I'm 
>>> interested in this from an efficiency standpoint. I can imagine a compiler 
>>> that analyzes whether a byte slice created from such a conversion is ever 
>>> modified and foregoing the copy in some cases, while still adhering to the 
>>> immutability guarantees.
>>>
>>> I have searched this forum for a past thread on this topic but have come 
>>> up empty. Feel free to point me to the relevant discussion.
>>>
>>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "golang-nuts" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/golang-nuts/C6BBNTRSEwg/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> golang-nuts...@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: efficiency of string <-> []byte conversion

2017-02-13 Thread Alex Flint
Thanks Val. I actually did a search before posting this and turned up many
of those same links, but it seems like they're all just reasoning from the
immutability of strings, which I don't think is quite sufficient to answer
the question in all cases. Anyway, thanks for your help and I think for now
I'll work on the assumption that string/byteslice conversions do always
copy.

On Mon, Feb 13, 2017 at 2:22 PM Val  wrote:

> Hello Alex,
> good point. I remember this has indeed come up in discussions in this
> forum.
>
> Searching "byte slice string copy" gave (among others) [1] [2] [3] [4] [5]
> [6] [7]. All of these look related to the suggested optimization "don't
> allocate© for a []byte to string, or string to []byte, conversion,
> under certain circumstances".
> Cheers
>  Val
>
> [1]
> https://groups.google.com/forum/#!searchin/golang-nuts/byte$20slice$20string$20copy|sort:relevance/golang-nuts/m46jaS6bgZg/R5hSOPFz5m0J
> [2]
> https://groups.google.com/forum/#!searchin/golang-nuts/byte$20slice$20string$20copy|sort:relevance/golang-nuts/CwoKDOhv6vw/sf35VZOZDQAJ
> [3]
> https://groups.google.com/forum/#!searchin/golang-nuts/byte$20slice$20string$20copy|sort:relevance/golang-nuts/ENgbUzYvCuU/gWa8V8wGAwAJ
> [4]
> https://groups.google.com/forum/#!searchin/golang-nuts/byte$20slice$20string$20copy|sort:relevance/golang-nuts/ajXzEM6lqJI/vRsqXxizBAAJ
> [5]
> https://groups.google.com/forum/#!searchin/golang-nuts/byte$20slice$20string$20copy|sort:relevance/golang-nuts/f2cX-BIJsqY/bzK77xpU8PMJ
> [6]
> https://groups.google.com/forum/#!searchin/golang-nuts/byte$20slice$20string$20copy|sort:relevance/golang-nuts/IfILC-wllaI/U8v88T3aBgAJ
> [7]
> https://groups.google.com/forum/#!searchin/golang-nuts/byte$20slice$20string$20copy|sort:relevance/golang-nuts/fXmG83gZOJg/eixtKSQiNysJ
>
>
> On Monday, February 13, 2017 at 9:31:06 PM UTC+1, Alex Flint wrote:
>
> As of go1.8, do conversions between strings and byte slices always
> generate a copy?
>
> I understand the immutability guarantees in the language spec, but I'm
> interested in this from an efficiency standpoint. I can imagine a compiler
> that analyzes whether a byte slice created from such a conversion is ever
> modified and foregoing the copy in some cases, while still adhering to the
> immutability guarantees.
>
> I have searched this forum for a past thread on this topic but have come
> up empty. Feel free to point me to the relevant discussion.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/golang-nuts/C6BBNTRSEwg/unsubscribe.
> To unsubscribe from this group and all its topics, 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.


[go-nuts] Re: efficiency of string <-> []byte conversion

2017-02-13 Thread Val
Hello Alex,
good point. I remember this has indeed come up in discussions in this forum.

Searching "byte slice string copy" gave (among others) [1] [2] [3] [4] [5] 
[6] [7]. All of these look related to the suggested optimization "don't 
allocate© for a []byte to string, or string to []byte, conversion, 
under certain circumstances".
Cheers
 Val

[1] 
https://groups.google.com/forum/#!searchin/golang-nuts/byte$20slice$20string$20copy|sort:relevance/golang-nuts/m46jaS6bgZg/R5hSOPFz5m0J
[2] 
https://groups.google.com/forum/#!searchin/golang-nuts/byte$20slice$20string$20copy|sort:relevance/golang-nuts/CwoKDOhv6vw/sf35VZOZDQAJ
[3] 
https://groups.google.com/forum/#!searchin/golang-nuts/byte$20slice$20string$20copy|sort:relevance/golang-nuts/ENgbUzYvCuU/gWa8V8wGAwAJ
[4] 
https://groups.google.com/forum/#!searchin/golang-nuts/byte$20slice$20string$20copy|sort:relevance/golang-nuts/ajXzEM6lqJI/vRsqXxizBAAJ
[5] 
https://groups.google.com/forum/#!searchin/golang-nuts/byte$20slice$20string$20copy|sort:relevance/golang-nuts/f2cX-BIJsqY/bzK77xpU8PMJ
[6] 
https://groups.google.com/forum/#!searchin/golang-nuts/byte$20slice$20string$20copy|sort:relevance/golang-nuts/IfILC-wllaI/U8v88T3aBgAJ
[7] 
https://groups.google.com/forum/#!searchin/golang-nuts/byte$20slice$20string$20copy|sort:relevance/golang-nuts/fXmG83gZOJg/eixtKSQiNysJ

On Monday, February 13, 2017 at 9:31:06 PM UTC+1, Alex Flint wrote:
>
> As of go1.8, do conversions between strings and byte slices always 
> generate a copy?
>
> I understand the immutability guarantees in the language spec, but I'm 
> interested in this from an efficiency standpoint. I can imagine a compiler 
> that analyzes whether a byte slice created from such a conversion is ever 
> modified and foregoing the copy in some cases, while still adhering to the 
> immutability guarantees.
>
> I have searched this forum for a past thread on this topic but have come 
> up empty. Feel free to point me to the relevant discussion.
>
>

-- 
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: Struggling with working directory

2017-02-13 Thread Sayth Renshaw
That's the one i used first but got errors that it couldn't find GOPATH
even though i installed it to the suggested default location.

So when that didn't work i delete the go directory and the details from
.profile and then followed ://
www.digitalocean.com/community/tutorials/how-to-install-go-1-6-on-ubuntu-16-04
.

Not sure why its being difficult.

Cheers

Sayth

On Mon, 13 Feb 2017, 11:41 PM Diego Medina  wrote:

> Can you include the link to the guide you followed to install Go?
>
> I always follow
> https://golang.org/doc/install#install
>
> which is, after downloading from the link on that page,:
>
> tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
>
> and then adding:
>
> /usr/local/go/bin to the PATH
>
>
> And I have never had to set GOBIN
>
> Thanks
>
> Diego
>
>
>
> On Mon, Feb 13, 2017 at 5:39 AM, Sayth Renshaw 
> wrote:
>
>
>
> On Sunday, 12 February 2017 04:16:15 UTC+11, Diego Medina wrote:
>
> Hi,
>
> you were very close, instead of
>
> go install github.com/mortalcatalyst/xml/xml.go
>
> do
>
> go install github.com/mortalcatalyst/xml
>
>
> In go, you don't install the particular file, you install the program as a
> whole (which in many cases, it involves more than one file)
>
> And as a side note, normally you would
>
> $ cd $GOPATH/src/github.com/mortalcatalyst/xml
> $ go install
>
>
> so you don't have to specify the whole path to the project every time.
>
> Hope that helps
>
> P.S. as you work with Go more and more, you'll want to add these lines to
> ~/.bash_profile:
>
> CDPATH=.:$GOPATH/src/github.com:$GOPATH/src/bitbucket.org #you may add
> more domains here if you host your proejct(s) somewhere else
> export CDPATH
>
> that let's you, form anywhere in your terminal, to type:
>
> $ cd mor
>
> Then press tab and the terminal will autocomplete mortalcatalyst
>
> P.S. source of the tip
> https://twitter.com/rob_pike/status/467367507305574400
>
> Diego
>
>
>
>
>
>
> Hi
>
> I now seem to have hit another problem
>
> sayth@sayth-E6410 ~/work/src/github.com/mortalcatalyst/xml $ go install
> github.com/mortalcatalyst/xml
> cannot install, GOBIN must be an absolute path
>
> An absolute path? I think somehow those directions have created a bad
> install.
>
> Is there a way I can reset to defaults and is there a better install
> method so that I can get a clean and working environment. Keep running into
> errors and cannot execute code.
>
> Cheers
>
> Sayth
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/golang-nuts/YE0w1Cbb1Ac/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> Diego Medina
> Lift/Scala Consultant
> di...@fmpwizard.com
> https://blog.fmpwizard.com/
>

-- 
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] Delve: Any way to get the "listing" of code when using "dlv attach " ?

2017-02-13 Thread Lax Clarke
Hi,

Is there any way to get the listing of code (i.e., "list" ) after doing dlv 
attach ?
That is, I want to build my golang binary such that attaching to it later 
gives me the line by line listing.

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.


[go-nuts] efficiency of string <-> []byte conversion

2017-02-13 Thread Alex Flint
As of go1.8, do conversions between strings and byte slices always generate 
a copy?

I understand the immutability guarantees in the language spec, but I'm 
interested in this from an efficiency standpoint. I can imagine a compiler 
that analyzes whether a byte slice created from such a conversion is ever 
modified and foregoing the copy in some cases, while still adhering to the 
immutability guarantees.

I have searched this forum for a past thread on this topic but have come up 
empty. Feel free to point me to the relevant discussion.

-- 
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: Reaching infinity

2017-02-13 Thread Nikita Loskutov
Hello again!

I thought about it today and I think I found solution for 4th infinity.
Check out 
here https://gist.github.com/cnaize/c106969508bdd898cc3b5026c110ed65
Any ideas how to increase to 5?

четверг, 17 ноября 2016 г., 1:58:04 UTC+4 пользователь Nikita Loskutov 
написал:
>
> Hello!
>
> I've wrote this small code snippet in *STRICTLY ACADEMIC PURPOSE*, see 
> comments.
> https://gist.github.com/cnaize/c106969508bdd898cc3b5026c110ed65
>
> As I think in this 2 lines of the code where are "3 infinities":
> 1 - infinity for loop
> 2 - goroutines infinity
> 3 - program itself infinity
>
> Is anybody know how to increase "infinities count"?
>

-- 
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] two questions

2017-02-13 Thread Will Donnelly

On Monday, February 13, 2017 at 10:35:39 AM UTC-8, Simon Perfer wrote:
>
> Thank you Zlatko.
>
>
> I actually have no idea how to call init_module() from my Go program. 
> Happy to do the legwork in figuring this out, but not even sure where to 
> start. 
>
Is there something I should Google to get my search started? What are the 
> keywords I should look up to begin this process?
>

Take a look at how the syscall package actually invokes a Linux syscall 
(https://golang.org/pkg/syscall/#Syscall). The syscall package appears to 
already define a constant "SYS_INIT_MODULE" with the appropriate syscall 
number for each supported platform, so in theory something like 
"syscall.Syscall(syscall.SYS_INIT_MODULE, )" is all you need to do.

Would calling this function preclude me from compiling a static binary?
>

Not if you do it via the syscall package.
 

> --
> *From:* golan...@googlegroups.com   > on behalf of Zlatko Čalušić  >
> *Sent:* Monday, February 13, 2017 1:06:54 PM
> *To:* golan...@googlegroups.com 
> *Subject:* Re: [go-nuts] two questions 
>  
> On 13.02.2017 17:50, Simon Perfer wrote:
>
> I've been working on a pet science project: building an initramfs with 
> only one file. Specifically, an executable written in Go.
>
>
> The only thing I can't figure out is how to do a "modprobe" in Go without 
> actually having the modprobe utility. Is there a libkmod library available? 
> If 
> not, how would I go about creating a wrapper for the libkmod library? 
> Never done this before.
>
>
> Finally, if I'm relying on C libraries like libkmod does this preclude me 
> from creating a statically-compiled binary? Goal being, again, that I am 
> creating an initramfs with only a single file: the compiled Go binary.
>
>
> Thanks!
>
>
> Hello Simon,
>
> that definitely looks like a nice project. I like simplicity. Do share 
> when you feel ready.
>
> I straced modprobe, and behind the scenes it just calls init_module(). So, 
> it should be pretty simple to call from Go.
>
> NAME
>init_module, finit_module - load a kernel module
>
> DESCRIPTION
>init_module() loads an ELF image into kernel  space,  performs  
> any  necessary  symbol
>relocations,  initializes module parameters to values provided by 
> the caller, and then
>runs the module's init function.  This system call requires 
> privilege.
>
> Hope it helps!
>
> -- 
> Zlatko
>
> -- 
> 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...@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] two questions

2017-02-13 Thread Simon Perfer
Thank you Zlatko.


I actually have no idea how to call init_module() from my Go program. Happy to 
do the legwork in figuring this out, but not even sure where to start.


Is there something I should Google to get my search started? What are the 
keywords I should look up to begin this process?


Would calling this function preclude me from compiling a static binary?


From: golang-nuts@googlegroups.com  on behalf of 
Zlatko Čalušić 
Sent: Monday, February 13, 2017 1:06:54 PM
To: golang-nuts@googlegroups.com
Subject: Re: [go-nuts] two questions

On 13.02.2017 17:50, Simon Perfer wrote:

I've been working on a pet science project: building an initramfs with only one 
file. Specifically, an executable written in Go.


The only thing I can't figure out is how to do a "modprobe" in Go without 
actually having the modprobe utility. Is there a libkmod library available? If 
not, how would I go about creating a wrapper for the libkmod library? Never 
done this before.


Finally, if I'm relying on C libraries like libkmod does this preclude me from 
creating a statically-compiled binary? Goal being, again, that I am creating an 
initramfs with only a single file: the compiled Go binary.


Thanks!


Hello Simon,

that definitely looks like a nice project. I like simplicity. Do share when you 
feel ready.

I straced modprobe, and behind the scenes it just calls init_module(). So, it 
should be pretty simple to call from Go.

NAME
   init_module, finit_module - load a kernel module

DESCRIPTION
   init_module() loads an ELF image into kernel  space,  performs  any  
necessary  symbol
   relocations,  initializes module parameters to values provided by the 
caller, and then
   runs the module's init function.  This system call requires privilege.

Hope it helps!

--
Zlatko


--
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] two questions

2017-02-13 Thread Zlatko Čalušić

On 13.02.2017 17:50, Simon Perfer wrote:


I've been working on a pet science project: building an initramfs with 
only one file. Specifically, an executable written in Go.



The only thing I can't figure out is how to do a "modprobe" in Go 
without actually having the modprobe utility. Is there a libkmod 
library available? If not, how would I go about creating a wrapper for 
the libkmod library? Never done this before.



Finally, if I'm relying on C libraries like libkmod does this preclude 
me from creating a statically-compiled binary? Goal being, again, that 
I am creating an initramfs with only a single file: the compiled Go 
binary.



Thanks!




Hello Simon,

that definitely looks like a nice project. I like simplicity. Do share 
when you feel ready.


I straced modprobe, and behind the scenes it just calls init_module(). 
So, it should be pretty simple to call from Go.


NAME
   init_module, finit_module - load a kernel module

DESCRIPTION
   init_module() loads an ELF image into kernel  space, performs  
any  necessary  symbol
   relocations,  initializes module parameters to values provided 
by the caller, and then
   runs the module's init function.  This system call requires 
privilege.


Hope it helps!

--
Zlatko

--
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] two questions

2017-02-13 Thread Simon Perfer
I've been working on a pet science project: building an initramfs with only one 
file. Specifically, an executable written in Go.


The only thing I can't figure out is how to do a "modprobe" in Go without 
actually having the modprobe utility. Is there a libkmod library available? If 
not, how would I go about creating a wrapper for the libkmod library? Never 
done this before.


Finally, if I'm relying on C libraries like libkmod does this preclude me from 
creating a statically-compiled binary? Goal being, again, that I am creating an 
initramfs with only a single file: the compiled Go binary.


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.


Re: [go-nuts] Looking for free, part-time, remote internship.

2017-02-13 Thread Malhar Vora
Hi Jacob,

Thanks for reply. I'll surely check links you have provided.

I agree with your suggestion regarding famous hot repos trending on Github.
I'll check them too.


Thanks,


Regds,
*Malhar Vora*
http://about.me/malhar.vora


On Mon, Feb 13, 2017 at 12:23 PM, Jakob Borg  wrote:

> You can probably assume by default that any open source project out there
> with open issues welcomes your help. :)
>
> On GitHub, you can list the most starred repos. These are projects that
> have been around for a long time and probably are fairly mature in
> welcoming new contributors. Definitely browse past the first page of
> results. I see Syncthing is still on there and we certainly welcome you. ;)
> The ones not obviously tied to a corporate backer may be more in need -
> although if you're looking for a position at one of the companies in
> question this could maybe be an inroad, I don't know.
>
> https://github.com/search?l=go&q=stars%3A%3E1&s=stars&;
> type=Repositories
>
> There are also the currently trending ones, although these may in some
> sense be the ones least in need of additional help since they are
> apparently getting lots of attention now anyway. But they are also hot (and
> cool) and probably get lots of bug reports if they are just coming into
> fame.
>
> https://github.com/trending/go?since=monthly
>
> Try to find something that you use yourself, or that uses a technology or
> solves a problem you find interesting.
>
> //jb
>
>
> > On 13 Feb 2017, at 03:09, Néstor  wrote:
> >
> > Hi,
> >
> > I like e in San Diego, California and I am in the same boat as Malhar,
> looking for a chance in the Golang world.
> >
> > Jonathan, how do you find out about open source projects  in Golang that
> need help?
> >
> > Thanks,
> >
> > Néstor
> >
> >
> > On Feb 12, 2017 5:35 PM, "Jonathan Yu"  wrote:
> > Have you considered contributing to an open source project of interest
> to you?
> >
> >
> > On Sun, Feb 12, 2017, 10:27 Malhar Vora  wrote:
> >
> >
> >
> >  Hi Everyone,
> >
> >  I am looking for part-time, remote internship kind of opportunity
> to work for completely free to learn Golang. Can anyone help me with that ?.
> >
> >  Just for your information I already have 3 years of experience in
> Python and zero experience in Golang.
> >
> >  Please inbox me at mlvora.2...@gmail.com.
> >
> >
> >
> >
> >
> >
> >
> >  Thanks,
> >  Malhar Vora
> >
> > --
> > 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.
> > --
> > Jonathan Yu / @jawnsy on LinkedIn, Twitter, GitHub, Facebook
> > “Ever tried. Ever failed. No matter. Try again. Fail again. Fail
> better.” — Samuel Beckett, Worstward Ho (1983)
> >
> > “In an adaptive environment, winning comes from adapting to change by
> continuously experimenting and identifying new options more quickly and
> economically than others. The classical strategist's mantra of sustainable
> competitive advantage becomes one of serial temporary advantage.” —
> Navigating the Dozens of Different Strategy Options (HBR)
> >
> >
> > --
> > 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.
>
>

-- 
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] Writing google cloud functions using go

2017-02-13 Thread martin8900
Google cloud functions will soon leave alpha and enter beta (I have heard). 
https://cloud.google.com/functions/

The issue in my mind is lack of golang support (you basically write node.js 
express handlers for http functions). So I tried fiddling with gopherjs to 
create a framework (eventuallly) to let you write idiomatic go code instead. As 
gopherjs does not really target node.js for production use there were some 
hurdles but I am on the way to creating something. Anybody with input on how 
this could be taken to be more reusable / abstracted?

https://github.com/MartinSahlen/go-cloud-fn is here the current code lives!

-- 
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] Handshake failed when using builtin TLS package: no cipher suite supported by both client and server

2017-02-13 Thread Alexandr Emelin
For history: we've made it work with Let's Encrypt issued certificates too: 
adding *ForceRSA: true* to autocert.Manager did the trick.

четверг, 9 февраля 2017 г., 10:48:08 UTC+3 пользователь Alexandr Emelin 
написал:
>
> Just tried trial certificate from Comodo - it works! So the problem is in 
> Let's Encrypt issued certs. Having such a workaround solves my issue, many 
> thanks for pointing me in right direction guys!
>
> среда, 8 февраля 2017 г., 21:09:00 UTC+3 пользователь cynexit.x написал:
>>
>> On 02/05/2017 09:44 AM, Alexandr Emelin wrote: 
>> > Chrome 49 on Windows XP SP3 
>>
>> Are you using a cert from let's encrypt? There have been issues in the 
>> past (although LE officially lists Windows XP with SP3 as supported), 
>> check these links out: 
>>
>>
>> https://github.com/certbot/certbot/issues/1660 
>>
>>
>> https://community.letsencrypt.org/t/lets-encrypt-certificates-do-not-work-on-xp-in-ie8-or-chrome/2654/13
>>  
>>
>> https://community.letsencrypt.org/t/xp-compatibility-issues/24277 
>>
>>
>> If possible try to buy a cert (there are some for ~5$) from someone else 
>> that is still selling SHA1 certs and try it again with that one. 
>>
>> My totally personal opinion however is to simply drop XP support. It's a 
>> dying and unsupported OS with some major security flaws, but I know that 
>> this route is not always an option. 
>>
>

-- 
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] [Proposal] Std Lib Logging Abstraction

2017-02-13 Thread Sotirios Mantziaris
i have already build such an abstraction myself 
(https://github.com/mantzas/adaptlog).
the issue is not what i use but what all the packages out there use that i 
import.
checkout the link mentioned by Dave Cheney

On Monday, February 13, 2017 at 4:18:58 PM UTC+2, Tamás Gulácsi wrote:
>
> Use an adapter which provides a writer to std lib's log, and pipes it 
> through your chosen logging lib.
> Like go-kit/kit/log.StdAdapter.

-- 
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] [Proposal] Std Lib Logging Abstraction

2017-02-13 Thread Tamás Gulácsi
Use an adapter which provides a writer to std lib's log, and pipes it through 
your chosen logging lib.
Like go-kit/kit/log.StdAdapter.

-- 
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: Struggling with working directory

2017-02-13 Thread Diego Medina
Can you include the link to the guide you followed to install Go?

I always follow
https://golang.org/doc/install#install

which is, after downloading from the link on that page,:

tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz

and then adding:

/usr/local/go/bin to the PATH


And I have never had to set GOBIN

Thanks

Diego



On Mon, Feb 13, 2017 at 5:39 AM, Sayth Renshaw 
wrote:

>
>
> On Sunday, 12 February 2017 04:16:15 UTC+11, Diego Medina wrote:
>>
>> Hi,
>>
>> you were very close, instead of
>>
>> go install github.com/mortalcatalyst/xml/xml.go
>>
>> do
>>
>> go install github.com/mortalcatalyst/xml
>>
>>
>> In go, you don't install the particular file, you install the program as
>> a whole (which in many cases, it involves more than one file)
>>
>> And as a side note, normally you would
>>
>> $ cd $GOPATH/src/github.com/mortalcatalyst/xml
>> $ go install
>>
>>
>> so you don't have to specify the whole path to the project every time.
>>
>> Hope that helps
>>
>> P.S. as you work with Go more and more, you'll want to add these lines to
>> ~/.bash_profile:
>>
>> CDPATH=.:$GOPATH/src/github.com:$GOPATH/src/bitbucket.org #you may add
>> more domains here if you host your proejct(s) somewhere else
>> export CDPATH
>>
>> that let's you, form anywhere in your terminal, to type:
>>
>> $ cd mor
>>
>> Then press tab and the terminal will autocomplete mortalcatalyst
>>
>> P.S. source of the tip https://twitter.com/rob_pi
>> ke/status/467367507305574400
>>
>> Diego
>>
>>
>>
>>
>>
>>
> Hi
>
> I now seem to have hit another problem
>
> sayth@sayth-E6410 ~/work/src/github.com/mortalcatalyst/xml $ go install
> github.com/mortalcatalyst/xml
> cannot install, GOBIN must be an absolute path
>
> An absolute path? I think somehow those directions have created a bad
> install.
>
> Is there a way I can reset to defaults and is there a better install
> method so that I can get a clean and working environment. Keep running into
> errors and cannot execute code.
>
> Cheers
>
> Sayth
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/golang-nuts/YE0w1Cbb1Ac/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Diego Medina
Lift/Scala Consultant
di...@fmpwizard.com
https://blog.fmpwizard.com/

-- 
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] The feature I want most, weak *

2017-02-13 Thread 'Axel Wagner' via golang-nuts
You can already achieve all of this without any kind of language change or
cooperation from the go-team. Just add an annotation in a comment (e.g.
"//foo:weak") on declarations of "weak" pointers and then have the tool
look for them and do its analysis.

On Mon, Feb 13, 2017 at 12:18 PM, Keynan Pratt  wrote:

> """
> But once you start saying that we are going to reject
> storing nil in an interface value unless it is weak, then you are
> greatly complicating the type system.
> """
> With regards to controls on nil this is a static analysis tool, not
> something I expect to be forced on anyone.
> As I understand it all interface types carry their concrete type with
> them, and this would only complain about the assignment of (nil, nil), it
> would not effect the zero value.
> Users of the official golang compiler would never even need to be told
> this is a thing. the golang compiler only needs to quietly throw away the
> weak keyword when it is found in type declaration such that any code
> written to an experimental fork could be safely built with the official
> compiler.
>
>
>
> On Mon, Feb 13, 2017 at 5:04 PM, Ian Lance Taylor  wrote:
>
>> On Fri, Feb 10, 2017 at 10:04 PM, Keynan Pratt 
>> wrote:
>> > Yes it CAN be implemented that way, but that throws away type
>> information,
>> > and makes code less readable.
>>
>> The question of compile-time type information boils down to the generics
>> issue.
>>
>> > It also seems to conflate the difference
>> > between language and library, i suppose go has already trod that bridge.
>> > What I'm asking for is something that can be used to reason about
>> programs
>> > at compile time. It seems like an opaque type at runtime wouldn't
>> achieve
>> > this. For example, if you where to implement this type could I still do
>> >
>> > var x interface{} = nil
>> >
>> > ?
>> >
>> > If you have weak as a language feature you can make that illegal,
>> insisting
>> > that only
>> >
>> > var x weak interface{} = nil
>> >
>> > is allowed, and any program written for a compiler that enforces
>> > non-nullable strong pointers would be valid to compile with the official
>> > compiler. Fast compile time is great, it's part of the reason I love
>> go. But
>> > it would be nice to have a flag I can turn on that gets me some of those
>> > wonderful correctness checking features that you see in languages with
>> > stronger type systems. Avoiding nulls just seems like the bare minimum.
>> So
>> > those are the things we theoretically get. On the other hand what is the
>> > cost of adding this? I suspect it is (very) small and I also
>> acknowledge it
>> > will never get added. I just think that's a shame.
>>
>> I'm sorry, but that doesn't seem to me like Go.  Go is a language with
>> a simple type system.  I can understand how weak pointers could fit
>> into Go.  But once you start saying that we are going to reject
>> storing nil in an interface value unless it is weak, then you are
>> greatly complicating the type system.  The cost of adding that kind of
>> complexity to the language is high.  The cost is not in
>> implementation--though I don't see offhand how to implement it, since
>> now non-weak interfaces have no zero value--the cost is in requiring
>> everybody learning the language to learn a complex new concept.
>>
>> 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.
>

-- 
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] The feature I want most, weak *

2017-02-13 Thread Keynan Pratt
"""
But once you start saying that we are going to reject
storing nil in an interface value unless it is weak, then you are
greatly complicating the type system.
"""
With regards to controls on nil this is a static analysis tool, not
something I expect to be forced on anyone.
As I understand it all interface types carry their concrete type with them,
and this would only complain about the assignment of (nil, nil), it would
not effect the zero value.
Users of the official golang compiler would never even need to be told this
is a thing. the golang compiler only needs to quietly throw away the weak
keyword when it is found in type declaration such that any code written to
an experimental fork could be safely built with the official compiler.



On Mon, Feb 13, 2017 at 5:04 PM, Ian Lance Taylor  wrote:

> On Fri, Feb 10, 2017 at 10:04 PM, Keynan Pratt 
> wrote:
> > Yes it CAN be implemented that way, but that throws away type
> information,
> > and makes code less readable.
>
> The question of compile-time type information boils down to the generics
> issue.
>
> > It also seems to conflate the difference
> > between language and library, i suppose go has already trod that bridge.
> > What I'm asking for is something that can be used to reason about
> programs
> > at compile time. It seems like an opaque type at runtime wouldn't achieve
> > this. For example, if you where to implement this type could I still do
> >
> > var x interface{} = nil
> >
> > ?
> >
> > If you have weak as a language feature you can make that illegal,
> insisting
> > that only
> >
> > var x weak interface{} = nil
> >
> > is allowed, and any program written for a compiler that enforces
> > non-nullable strong pointers would be valid to compile with the official
> > compiler. Fast compile time is great, it's part of the reason I love go.
> But
> > it would be nice to have a flag I can turn on that gets me some of those
> > wonderful correctness checking features that you see in languages with
> > stronger type systems. Avoiding nulls just seems like the bare minimum.
> So
> > those are the things we theoretically get. On the other hand what is the
> > cost of adding this? I suspect it is (very) small and I also acknowledge
> it
> > will never get added. I just think that's a shame.
>
> I'm sorry, but that doesn't seem to me like Go.  Go is a language with
> a simple type system.  I can understand how weak pointers could fit
> into Go.  But once you start saying that we are going to reject
> storing nil in an interface value unless it is weak, then you are
> greatly complicating the type system.  The cost of adding that kind of
> complexity to the language is high.  The cost is not in
> implementation--though I don't see offhand how to implement it, since
> now non-weak interfaces have no zero value--the cost is in requiring
> everybody learning the language to learn a complex new concept.
>
> 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.


[go-nuts] Re: Panic in go1.8rc3 using cgo to get binary data from database

2017-02-13 Thread Mark Crook
Thanks Daniel, that seems on the right track.

The driver api itself is a C library, without source code.

>From the driver api docs:

/** 
* get_column() fills the supplied buffer with the value fetched for the
* specified column. *For A_BINARY and A_STRING * data types,*
* * value->buffer will point to an internal buffer associated with the 
result set.*
* The content of the pointer buffer should not be relied on or altered
* as it will change when a new row is fetched or when the result set
* object is freed. Users should copy the data out of those pointers into 
their
* own buffers. The length field indicates the number of valid characters 
that
* buffer->buffer points to. The data returned in buffer->buffer is not
* null-terminated. This function fetches all of the returned value from the 
server.
* For example, if the column contains
* a 2GB blob, this function will attempt to allocate enough memory to hold 
that value.
* If this is not desired, get_data() should be used instead.
* 
* returns 1 on success or 0 for failure. A failure can happen if any of the 
parameters is invalid 
* or if there is not enough memory to retrieve the full value from the 
server.
*/
get_column( a_stmt * stmt, u32 col_index, a_data_value * value );


Here's an outline of a C implementation. This is what I want to replace 
with Go:

 typedef struct a_data_value
 {
 char * buffer; //allocated by caller except for binary & string type
 size_t buffer_size; //set by caller except for binary & string type
 size_t * length; //The number of valid bytes in the buffer. Must be 
less than buffer_size 
 a_data_type type;
 bool * is_null;
 } a_data_value;

 char * blob;
 size_t size;
 a_data_value value;

 err = get_column( stmt_handle, column_index, &value )

 char * buffer = (char *)emalloc( *(value.length) );
 memcpy( buffer, val.buffer, *(value.length) );
 size = *(val.length)



An attempt in Go, occasionally panics:


value := new(C.a_sqlany_data_value)
C.sqlany_get_column(r.stmt.ptr, col_index, value)
blob := C.GoBytes(unsafe.Pointer(value.buffer), C.int(value.length))



Another attempt, allocating value in c memory, here the call to free 
occasionally panics:
   

value := (*C.a_data_value)(C.malloc(C.sizeof_a_data_value))
defer C.free(unsafe.Pointer(value))

C.sqlany_get_column(r.stmt.ptr, col_index, value)
blob := C.GoBytes(unsafe.Pointer(value.buffer), C.int(value.length))



Assigning the value directly appears to panic more frequently:


blob = (*[1 << 30]byte)(unsafe.Pointer(r.value.buffer))[:*value.length:*
value.length]




Note:
 - null checks and get_column error check aren't shown here. 
 - each query returns many rows each with a single binary column value up 
to around 10Mb

Any suggestions appreciated!
Thanks,
Mark

On Monday, 13 February 2017 12:51:28 UTC+13, Daniel Theophanes wrote:
>
> It is difficult to be certain, but I would put my bets on your sql 
> anywhere driver may not be handling the c data lifetimes correctly, or 
> might not be keeping a reference. It is difficult to tell without the 
> driver code.
>
> Thanks, -Daniel
>
> On Saturday, February 11, 2017 at 7:27:11 PM UTC-8, Mark Crook wrote:
>>
>> Hello,
>>
>> I'm seeing a panic in go version go1.8rc3 linux/amd64 while trying to 
>> write a database driver using cgo. The go code runs in a docker container, 
>> the database in another.
>>
>> Generally it works reliably, but occasionally, during repeated retrieval 
>> of binary data (photos approx 100K to 2M), the code panics.
>>
>> I haven't isolated a reproducible example, but I think it's related to 
>> this code:
>>
>>
>> value := new(C.a_sqlany_data_value)
>>
>> //load the column value binary data into value.buffer
>>
>> C.sqlany_get_column(r.stmt.ptr, C.sacapi_u32(i), value)
>>
>>
>> //copy the value buffer from C to Go
>>
>> val = C.GoBytes(unsafe.Pointer(value.buffer), C.int(value.length))
>>
>>
>> I haven't seen the panic if the last line is commented out.
>>
>> Below is a stack trace. Perhaps it panics when a garbage collection is 
>> triggered while waiting for C.GoBytes to return?
>>
>> Any suggestions?
>>
>> Thank you,
>> Mark
>>
>>  
>>
>> runtime: unexpected return pc for runtime.sigpanic called from 
>> 0xc420e1a000
>> fatal error: unknown caller pc
>>
>> runtime stack:
>> runtime.throw(0x59a90e, 0x11)
>> /go/src/runtime/panic.go:596 +0x95
>> runtime.gentraceback(0x, 0xc42002a5d8, 0x0, 0xc4200c49c0, 
>> 0x0, 0x0, 0x7fff, 0x7fb675ad5cb8, 0x0, 0x0, ...)
>> /go/src/runtime/traceback.go:317 +0x13ea
>> runtime.scanstack(0xc4200c49c0, 0xc420021828)
>> /go/src/runtime/mgcmark.go:842 +0x265
>> runtime.newstack(0x0)
>> /go/src/runtime/stack.go:1064 +0x41e
>> runtime.morestack()
>> /go/src/runtime/asm_amd64.s:398 +0x86
>>
>> goroutine 11 [GC worker (idle) (scan)]:
>> runtime.assertE2I2(0x56c220, 0x569e20, 0x841d20, 0xc42002a6b0, 
>> 0xc4200c49e0, 0xc42002a640)
>> /go/src/runtime/iface.go:289 +0xb2 fp=0xc42002a5e0 sp=0xc42002a5d8
>> runtime.prepri

[go-nuts] Re: Struggling with working directory

2017-02-13 Thread Sayth Renshaw


On Sunday, 12 February 2017 04:16:15 UTC+11, Diego Medina wrote:
>
> Hi,
>
> you were very close, instead of
>
> go install github.com/mortalcatalyst/xml/xml.go
>
> do
>
> go install github.com/mortalcatalyst/xml
>
>
> In go, you don't install the particular file, you install the program as a 
> whole (which in many cases, it involves more than one file)
>
> And as a side note, normally you would 
>
> $ cd $GOPATH/src/github.com/mortalcatalyst/xml
> $ go install
>
>
> so you don't have to specify the whole path to the project every time.
>
> Hope that helps
>
> P.S. as you work with Go more and more, you'll want to add these lines to 
> ~/.bash_profile:
>
> CDPATH=.:$GOPATH/src/github.com:$GOPATH/src/bitbucket.org #you may add 
> more domains here if you host your proejct(s) somewhere else
> export CDPATH
>
> that let's you, form anywhere in your terminal, to type:
>
> $ cd mor 
>
> Then press tab and the terminal will autocomplete mortalcatalyst
>
> P.S. source of the tip 
> https://twitter.com/rob_pike/status/467367507305574400
>
> Diego
>
>
>
>
>
>
Hi

I now seem to have hit another problem  

sayth@sayth-E6410 ~/work/src/github.com/mortalcatalyst/xml $ go install 
github.com/mortalcatalyst/xml
cannot install, GOBIN must be an absolute path

An absolute path? I think somehow those directions have created a bad 
install.

Is there a way I can reset to defaults and is there a better install method 
so that I can get a clean and working environment. Keep running into errors 
and cannot execute code.

Cheers

Sayth

-- 
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] [Proposal] Std Lib Logging Abstraction

2017-02-13 Thread Sotirios Mantziaris
nice, i'll take a look

On Monday, February 13, 2017 at 10:00:15 AM UTC+2, Dave Cheney wrote:
>
> There is an active discussion thread over on the development list -> 
> https://groups.google.com/forum/#!topic/golang-dev/F3l9Iz1JX4g

-- 
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] [Proposal] Std Lib Logging Abstraction

2017-02-13 Thread Dave Cheney
There is an active discussion thread over on the development list -> 
https://groups.google.com/forum/#!topic/golang-dev/F3l9Iz1JX4g

-- 
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.