[go-nuts] How to pass a go file name as arguments to go run

2017-01-05 Thread Mandolyte
Pass as a value to a named argument: 
go run cmd/main.go -input tests/dir/a.go

-- 
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: how go cast multi return value type

2017-01-05 Thread djadala


On Friday, January 6, 2017 at 4:01:32 AM UTC+2, hui zhang wrote:
>
>
> check code below
> func foo() (int32,int32) {
> .
> }
> var a,b int16
> a, b = (int16, int16)foo()
>
> I want to cast multi return value ,  but it seems impossible in go,  how 
> can I do that
> I just want to make my code short , and not wish to create useless temp 
> variable
>
>
>

Hi,
you can use function to convert types:
https://play.golang.org/p/2mBwvXhUI9
 
Djadala

-- 
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] How can I compare the interface in a generic function

2017-01-05 Thread Ian Lance Taylor
On Thu, Jan 5, 2017 at 5:29 PM, hui zhang  wrote:
>
> How can I compare the interface ?
> I want to implement a generic function.
> the <=>=  report error in this code
>
> func InRange(a, b, c interface{}) bool {
>if c >= a && c <= b {
>   return true
>} else {
>   return false
>}
> }

You can only compare interface values for equality.

To compare for ordering you need to use a type assertion or type
switch to some type that supports ordering.  Or if, for example, you
know that the values contain signed integers, you could use
reflect.ValueOf(a).Int().

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] how go cast multi return value type

2017-01-05 Thread Ian Lance Taylor
On Thu, Jan 5, 2017 at 5:24 PM,   wrote:
>
> check code below
> func foo() (int32,int32) {
> .
> }
> var a,b int16
> a, b = (int16, int16)foo()
>
> I want to cast multi return value ,  but it seems impossible in go,  how can
> I do that
> I just want to make my code short , and not wish to create useless temp
> variable

Sorry, you need the temporary variables.

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] How can I compare the interface in a generic function

2017-01-05 Thread hui zhang
How can I compare the interface ?
I want to implement a generic function.
the <=>=  report error in this code

func InRange(a, b, c interface{}) bool {
   if c >= a && c <= b {
  return true
   } else {
  return false
   }
}

-- 
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] how go cast multi return value type

2017-01-05 Thread fastfading

check code below
func foo() (int32,int32) {
.
}
var a,b int16
a, b = (int16, int16)foo()

I want to cast multi return value ,  but it seems impossible in go,  how 
can I do that
I just want to make my code short , and not wish to create useless temp 
variable


-- 
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] Proposal for a succinct error return syntax

2017-01-05 Thread xjru
Here are some examples for valid error returns according to my proposal:


file, err := os.Open(fname) ||| return err

file, err := os.Open(fname) ||| panic(err)

file, err := os.Open(fname) ||| return errors.Wrap(err, "too bad")


The third example uses the Wrap function from github.com/pkg/errors. The 
||| operator is not important. It could be any operator, but the idea 
behind the tripple bar is to signal a special kind of or. I can imagine 
using the keyword "orr" instead.

The semantics is pretty simple. If there is an (possibly multiple) 
assignment whose last component conforms to the error interface, then it 
may be followed by ||| and a single statement that must either return or 
panic.

You might argue that this isn't much longer:

if file, err := os.Open(fname); err != nil {
return err
}

However, this has the unfortunate side effect of putting file into the 
scope of the if block. That's why we often have to use

file, err := os.Open(fname)
if err != nil {
return err
}

I think my proposal has a couple of benefits.

   - It is perhaps not too magical (just a little bit because the condition 
   is implied by the ||| operator).
   - I doesn't obscure the clear view on the assignment statement itself 
   (unlike Rust's try! macro).
   - The keywords return or panic make it very clear what happens to 
   control flow (unlike Rust's try! macro).
   
It does have the drawback that it is a unique special case for errors not 
based on a more general language facility. It makes the language a little 
bit more complex. But I think errors are frequent enough to deserve a 
little bit of syntactic sugar.

Apologies if this has been discussed to death.

-- 
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: Facing linker issues while cross-compiling from Ubuntu/amd64 to darwin/amd64

2017-01-05 Thread Koichi Shiraishi (zchee)
Hi, Kedar.

Is o64-clang is probably osxcross? If so, it seems to the same situation on 
my zchee/docker-machine-driver-xhyve 
 projects CircleCI 
build testing. yml is here. circle.yml 

This project using "Hypervisor.framework" and "vmnet.framework"(which 
darwin specific Libraries), so also uses cgo build. But successfully on 
Ubuntu xenial in the docker container.
https://circleci.com/gh/zchee/docker-machine-driver-xhyve/270

I'm made the small Dockerfile that tiny wrapper of osxcross runtime for 
this project, called osxcc.
https://github.com/osxcc/osxcc
https://github.com/osxcc/golang

It is not necessary to actually build your code with using it, and I don't 
know why undefined some symbols. But I hope you find shell commands in 
Dockerfile informative.

- zchee aka Koichi Shiraishi


On Friday, January 6, 2017 at 12:28:16 AM UTC+9, Kedar Babar wrote:
>
> Hi,
> I had written a small go program, which refers the 'C' code, following 
> is the snippet
>
> package main
>
> /*
> #include 
> */
> import "C"
> import "fmt"
>
> const cgoAddrInfoFlags = (C.AI_CANONNAME | C.AI_V4MAPPED | C.AI_ALL) & 
> C.AI_MASK
>
> func main() {
> fmt.Println("Hello")
> } 
>
> When i build the above program, i get the below linking errors for the 
> target darwin/amd64.
> /usr/lib/go-1.6/pkg/tool/linux_amd64/link: running o64-clang failed: exit 
> status 1
> ld: warning: ignoring file /tmp/go-link-601229876/01.o, file was built 
> for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00 
> 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being 
> linked (x86_64): /tmp/go-link-601229876/01.o
> Undefined symbols for architecture x86_64:
>   "__cgo_wait_runtime_init_done", referenced from:
>   _callbackTrampoline in 00.o
>   _stepTrampoline in 00.o
>   _doneTrampoline in 00.o
>   "_x_cgo_free", referenced from:
>   __cgo_free in go.o
>   "_x_cgo_init", referenced from:
>   __cgo_init in go.o
>   "_x_cgo_malloc", referenced from:
>   __cgo_malloc in go.o
>   "_x_cgo_notify_runtime_init_done", referenced from:
>   __cgo_notify_runtime_init_done in go.o
>   "_x_cgo_setenv", referenced from:
>   runtime._cgo_setenv in go.o
>   "_x_cgo_thread_start", referenced from:
>   __cgo_thread_start in go.o
>   "_x_cgo_unsetenv", referenced from:
>   runtime._cgo_unsetenv in go.o
> ld: symbol(s) not found for architecture x86_64
> clang: error: linker command failed with exit code 1 (use -v to see 
> invocation)
>
> *Following is the go command used to build the above stuff.*
> env CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=o64-clang go build -x -work 
> -ldflags="-extld=o64-clang"
>
>
>
>

-- 
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: Accessing an slice is too slow than Array

2017-01-05 Thread Dave Cheney
and at the end of the day, the difference per access is 1ns, 3-4 
instructions on a modern Intel processor.

On Friday, 6 January 2017 11:21:32 UTC+11, Keith Randall wrote:
>
> You're not really testing what you think you are testing.
>
> When you do "_ = load something", the compiler just throws away the load. 
>  You have to use the result somehow to keep the load in the final assembly.
>
> What you are actually timing is the speed of the modulo operator (%).
>
> For the pointer case, you're doing unsigned i % 256, which the compiler 
> reduces to i&255.
> For the array case, you're doing signed i % 256, which the compiler 
> reduces to a multiply/few shift combo.
> For the slice case, you're doing signed i % j, as the compiler can't 
> assume the length of the slice is always 256 (as it is a mutable global). 
>  That requires an actual hardware divide instruction plus some fixup code.
>
> Bottom line - microbenchmarking is hard.
>
> On Thursday, January 5, 2017 at 4:02:09 AM UTC-8, Uli Kunitz wrote:
>>
>> A few comments:
>>
>> For such microbenchmarks you need to check the assembler for 
>> optimizations. The C code probably removed the complete loop.
>>
>> The Go version and machine architecture is relevant. There were 
>> significant changes recently, particular with the introduction of SSA 
>> (static single assignment) for amd64.
>>
>> Usally for _, x := range  is much faster than direct 
>> access. 
>>
>> The difference between array and slice is probably that the slice access 
>> must read the pointer to the backing array before the actual value can be 
>> accessed. This step is not required for arrays.
>>
>

-- 
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: Accessing an slice is too slow than Array

2017-01-05 Thread 'Keith Randall' via golang-nuts
You're not really testing what you think you are testing.

When you do "_ = load something", the compiler just throws away the load. 
 You have to use the result somehow to keep the load in the final assembly.

What you are actually timing is the speed of the modulo operator (%).

For the pointer case, you're doing unsigned i % 256, which the compiler 
reduces to i&255.
For the array case, you're doing signed i % 256, which the compiler reduces 
to a multiply/few shift combo.
For the slice case, you're doing signed i % j, as the compiler can't assume 
the length of the slice is always 256 (as it is a mutable global).  That 
requires an actual hardware divide instruction plus some fixup code.

Bottom line - microbenchmarking is hard.

On Thursday, January 5, 2017 at 4:02:09 AM UTC-8, Uli Kunitz wrote:
>
> A few comments:
>
> For such microbenchmarks you need to check the assembler for 
> optimizations. The C code probably removed the complete loop.
>
> The Go version and machine architecture is relevant. There were 
> significant changes recently, particular with the introduction of SSA 
> (static single assignment) for amd64.
>
> Usally for _, x := range  is much faster than direct access. 
>
> The difference between array and slice is probably that the slice access 
> must read the pointer to the backing array before the actual value can be 
> accessed. This step is not required for arrays.
>

-- 
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] Mutagen - A unique file sync utility in Go inspired by Unison

2017-01-05 Thread Jacob Howard
Syncthing's transfer model is a bit different with it's block-exchange 
protocol, so it's a bit difficult to compare the exact behavior.  For most 
use cases, I think you'd see comparable performance in terms of data 
transfer required for change propagation, though Mutagen could perform a 
few additional optimizations that it doesn't currently do, e.g. optimizing 
rsync block size based on file size, but these would be very marginal gains.

-Jacob

On Thursday, January 5, 2017 at 7:13:06 PM UTC+2, wilk wrote:
>
> On 05-01-2017, Shawn Milochik wrote: 
> > --94eb2c1a09e43b9d8205455b0873 
> > Content-Type: text/plain; charset=UTF-8 
> > 
> > I really like the idea of what you have here. I'm currently using 
> SyncThing 
> > for this purpose. SyncThing seems to fit all your requirements with the 
> > exception of only needing to be installed on one of the machines. 
> However, 
> > in return SyncThing allows you to select which folders are shared from 
> each 
> > machine to each other machine, making it really useful for sharing only 
> a 
> > subset of your data with other people. https://syncthing.net/ 
>
> The bonus of syncthing is also deduplication on whole files right ? 
> Mutagen will do it also ? 
>
>
>
> -- 
> William 
>
>

-- 
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] [ANN] Mutagen - A unique file sync utility in Go inspired by Unison

2017-01-05 Thread Jacob Howard
Thanks for the questions!

Syncthing is, as you say, aimed at being a Dropbox replacement.  It is 
designed to be set up for long-term synchronization sessions.  Mutagen was 
designed for more ephemeral syncing, particularly for remote code editing. 
 Its ancestry really lies closer to something like Unison, rmate, or 
Sublime SFTP.  It just so happened that the final design of Mutagen worked 
decently for long-term synchronization as well.

I also wanted to make Mutagen simpler to use than Syncthing.  When you open 
up the Syncthing docs , it can take some time 
to get your bearings, and I suspect the setup is a barrier to entry for a 
lot of people who aren't experts and just want to sync files.  I wanted 
anyone who knew how to use SSH to be able to use this instantly.

I also wanted this to operate over SSH rather than a custom TCP port.  Most 
remote systems that you might want to edit code on aren't going to let you 
forward a TCP port through their firewalls like you'd need to do for 
Syncthing, so then you're tunneling over SSH and it's kind of complicated.

Finally, as you mention, you don't need to install on the remote.  This 
sounds trivial, but it helps solve a lot of issues with systems that you 
don't control.

So to answer your question, basically it's short-term and simple vs 
long-term and more complex.  Syncthing has a lot of nice configuration 
options and can do a lot of cool things, and this doesn't replace that. 
 For people who don't know what SSH is, Sycnthing is also probably still 
the way to go, especially on home networks.  For people who need to edit a 
directory on a remote system that they don't necessarily have extensive 
control over and don't want to deal with the flakiness of SSHFS or SFTP, 
Mutagen is hopefully going to be the way to go.

-Jacob


On Thursday, January 5, 2017 at 6:03:10 PM UTC+2, Shawn Milochik wrote:
>
> I really like the idea of what you have here. I'm currently using 
> SyncThing for this purpose. SyncThing seems to fit all your requirements 
> with the exception of only needing to be installed on one of the machines. 
> However, in return SyncThing allows you to select which folders are shared 
> from each machine to each other machine, making it really useful for 
> sharing only a subset of your data with other people. 
> https://syncthing.net/
>
> If you're familiar with SyncThing (or if not, it's kind of like 
> Dropbox/btsync but without a middleman or closed-source protocols), what's 
> the case for using mutagen instead of (or as well as) SyncThing?
>
> Thanks for sharing!
>
> Shawn
>
>
>

-- 
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] fmt verb to single quote text

2017-01-05 Thread bsr
Andrew.. thank you so much. that works great..

On Thursday, January 5, 2017 at 3:37:51 PM UTC-5, Diddymus wrote:
>
> Maybe https://play.golang.org/p/9EewyQhD3U ?
>
> On Thursday, 5 January 2017 17:06:07 UTC, bsr wrote:
>>
>> Alexander. thank you very much for helping out. 
>> your program does output my desired string, but value is read from 
>> parsing struct comment and not sure how to get the same effect of multi 
>> line string `hello ... \n world`
>> In other word, my input is "hello ... \n world" and not sure how to 
>> convert to support multi line string like `hello ... \n world`
>> thanks in advance,
>> bsr.
>>
>>
>>
>> On Thursday, January 5, 2017 at 11:52:39 AM UTC-5, Alexander Kapshuk 
>> wrote:
>>>
>>> On Thu, Jan 5, 2017 at 6:45 PM, bsr  wrote: 
>>> > Please see the example https://play.golang.org/p/SeG7oO5Us0 
>>> > 
>>> > I am doing some javascript codegen and I want my values single quoted. 
>>> so, 
>>> > in the above example, I want the output to be 
>>> > 
>>> > 
>>> > { v: 'hello ... \n world'} 
>>> > 
>>> > 
>>> > instead of 
>>> > 
>>> > { v: '"hello ... \n world"'}  or { v: "hello ... \n world"} 
>>> > 
>>> > how can I do that? 
>>> > 
>>> > thanks, 
>>> > bsr. 
>>> > 
>>> > -- 
>>> > 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. 
>>>
>>> https://play.golang.org/p/GEQpdi6C6s 
>>>
>>

-- 
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] Multiplexing blocking call on Go routine

2017-01-05 Thread zohaibsh
I think there a confusion of what I am trying to say. With the go routine 
approach there is cost of 1M connections + cost of 1M go routines running a 
blocking call all the time. With an event based system where I can 
multiplex code execution over a fixed size go routines, the cost is already 
cut in half because I can do 1M connections + cost of 1K go routines. But I 
get the gist, there is no way for me except to go really go on something 
like libuv.

On Wednesday, 4 January 2017 19:14:32 UTC-8, Jesse McNelis wrote:
>
> On Thu, Jan 5, 2017 at 9:51 AM,  > wrote: 
> > Hey guys, 
> > 
> >  So for some time now I have been trying to build a high performance 
> Pub/Sub 
> > server in Go. I am using gorilla websocket library, which in it self has 
> a 
> > Read, Write methods 
> > (https://godoc.org/github.com/gorilla/websocket#Conn.ReadMessage) that 
> will 
> > block my current routine. In order to continuously listen to messages 
> coming 
> > from client I spin off a go routine, reading from socket and pushing 
> > messages over a channel. Which I in-turn can use for doing select { } in 
> > another go routine. When I testing this thing for scaling, I just wrote 
> some 
> > test code and turns out spinning off 1M go routines (doing nothing) 
> results 
> > in ~8GB of memory usage on my windows machine. 
>
> You should compare this with a simple C program using epoll, you'll 
> find that maintaining a 1M connections uses quite a lot of memory. 
>
> >These go routines are doing 
> > nothing (sleeping) and it requires this much memory; which forced me to 
> ask 
> > if I can multiplex such blocking calls on a single go routine. If I can 
> do 
> > so I can spin off something like 1000 go routines and each one of them 
> > multiplexing 1000 connections (which in theory should require lesser 
> memory 
> > that what I am currently getting). 
>
> But a real program won't holding 1M connections and doing nothing with 
> them. 
> The cost of processing requests from those connections will be much 
> larger than the cost of a goroutine. 
>
>
> >  Any ideas how can one call muiltple socket reads (something like event 
> > loop) on single go routine. 
>
> There really isn't a way, The net package already provides a 
> lightweight way to maintain larger numbers of connections using 
> goroutines. 
>
>
> > Disclaimer: I know event loop may sound against the golang philosophy 
> but I 
> > see no reason to pay such huge memory cost when most of them will be 
> idle, 
> > waiting for something to come from user. 
>
> I think you're underestimating the memory cost of simply having 1M 
> connections. 
>

-- 
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: ServeMux: support for PATH_INFO and arguments

2017-01-05 Thread Manlio Perillo
Il giorno giovedì 5 gennaio 2017 21:58:18 UTC+1, v.pu...@gmail.com ha 
scritto:
>
> You can try: 
> https://github.com/pressly/chi


These routers all have the same problems:

* Non standard coding style (some seems to not use go fmt)
* Registering a GET handler does not also register an HEAD handler ( 
https://github.com/bmizerany/pat: is an exception)
* They only support standard HTTP method; but what about if I want to use 
other methods?
* Some, like chi, are over- engineered (IMHO, of course).
   chi Router interface is absurd; interfaces should not be that big.


Thanks
Manlio

-- 
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] ServeMux: support for PATH_INFO and arguments

2017-01-05 Thread v . pupillo
You can try:
https://github.com/pressly/chi

-- 
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] Unmarshal mixed XML content

2017-01-05 Thread Shawn Milochik
On Thu, Jan 5, 2017 at 2:40 PM, John Leidegren 
wrote:

> See https://play.golang.org/p/XjKdm7Pooh
>
> I was hoping to get back a, b followed by c but I get a, c then b. I just
> can't get this to work.
>
> How is it even possible for it to read character data from before and
> after the B node?
>
>
The problem is that there is no C. A gets the characters from the 
element, and B gets the b from the  element:

https://play.golang.org/p/czAXksSYMo

I don't think you can get what you want from the XML unmarshal if 'a' and
'c' are going to be chardata in the same element. You may just have to put
them in separate elements or parse the 'A' value to get the two separate
strings.

-- 
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] fmt verb to single quote text

2017-01-05 Thread Diddymus
Maybe https://play.golang.org/p/9EewyQhD3U ?

On Thursday, 5 January 2017 17:06:07 UTC, bsr wrote:
>
> Alexander. thank you very much for helping out. 
> your program does output my desired string, but value is read from parsing 
> struct comment and not sure how to get the same effect of multi line string 
> `hello ... \n world`
> In other word, my input is "hello ... \n world" and not sure how to 
> convert to support multi line string like `hello ... \n world`
> thanks in advance,
> bsr.
>
>
>
> On Thursday, January 5, 2017 at 11:52:39 AM UTC-5, Alexander Kapshuk wrote:
>>
>> On Thu, Jan 5, 2017 at 6:45 PM, bsr  wrote: 
>> > Please see the example https://play.golang.org/p/SeG7oO5Us0 
>> > 
>> > I am doing some javascript codegen and I want my values single quoted. 
>> so, 
>> > in the above example, I want the output to be 
>> > 
>> > 
>> > { v: 'hello ... \n world'} 
>> > 
>> > 
>> > instead of 
>> > 
>> > { v: '"hello ... \n world"'}  or { v: "hello ... \n world"} 
>> > 
>> > how can I do that? 
>> > 
>> > thanks, 
>> > bsr. 
>> > 
>> > -- 
>> > 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. 
>>
>> https://play.golang.org/p/GEQpdi6C6s 
>>
>

-- 
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] ServeMux: support for PATH_INFO and arguments

2017-01-05 Thread Manlio Perillo
I'm using Go for a web application and currently I'm using the standard 
ServeMux since I don't need fancy features.
The only features I need are PATH_INFO, and routing args.

Unfortunately I have searched a few external packages but they all have 
some problems.

* https://github.com/julienschmidt/httprouter: unfortunately the HTTP 
handler is not compatible with the standard HTTP handler, since parameters 
are passed as an additional argument.

* https://github.com/bmizerany/pat:  stores the parameters in Request.URL, 
but does not have PATH_INFO (instead if has a Tail function)

* https://github.com/go-zoo/bone: stores parameters in the request context 
(good), but for older version of Go it stores them in a global variable.
   Still, there is no support for PATH_INFO and the coding style is not the 
best.

Any other choices?


Thanks  Manlio

-- 
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] Unmarshal mixed XML content

2017-01-05 Thread John Leidegren
See https://play.golang.org/p/XjKdm7Pooh

I was hoping to get back a, b followed by c but I get a, c then b. I just 
can't get this to work.

How is it even possible for it to read character data from before and after 
the B node?

-- 
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] Typed encoding

2017-01-05 Thread Daniel Martí
Hello all,

I wrote a package that parses a language (bash) and constructs an AST. I
would like to make it easier for other tools to use it, even outside of
Go.

I'm aware that Go can be built as a shared library, but I'd like to go a
simpler route especially for scripting languages.

What encoding would suit best? I initially thought something like
encoding/json, which would work fairly well to give data. But it starts
to break with interfaces. For example:

https://godoc.org/github.com/mvdan/sh/syntax#Stmt

Once in json, the type information is lost and needs to be inferred.
This could still be okay.

But the problem is unmarshalling back, e.g. if the script modifies the
AST and Go wishes to read it back to, for example, write the modified
version into a formatted .sh file.

I'm expecting this to not work at all, since the best it could do is
map[string]interface{}.

What encoding/format should I use? I'm aware of "typed" wire encodings
like grpc's, but that's probably too overkill for this.

I was thinking of switching back and forth between the true types and
map[string]interface{} manually via reflect, adding "Type" fields to
each interface value. But as you can imagine, that's a lot of
boilerplate. And I'm fairly sure there has to be something for this.

-- 
Daniel Martí - mv...@mvdan.cc - https://mvdan.cc/

-- 
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] Issue #5932 (net: do not wait on EAGAIN from lossy packet conn)

2017-01-05 Thread anner
Hi,

I'd like to respond to #5932 , but can't 
because it is locked.

Earlier we had issues (see comment 17), however it seems to be fixed in 
1.7.4 and also a couple of versions ago (1.5, 1.6).

The tested kernel version is:
Linux 3.2.0-4-amd64 #1 SMP Debian 3.2.73-2+deb7u3 x86_64

I've used the source code from comment 17 to reproduce the issue.

Kind regards,
Anner van Hardenbroek

-- 
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] explain CLA terms

2017-01-05 Thread Ian Lance Taylor
On Wed, Jan 4, 2017 at 10:58 PM, Xavier Combelle
 wrote:
> Le 05/01/2017 à 07:01, Ian Lance Taylor a écrit :
>
>> On Wed, Jan 4, 2017 at 8:21 PM, Xavier Combelle
>>  wrote:
>>> I was interested in contributing in golang, but was afraid to contribute
>>> because of signing the CLA. After rereading it, I thought that I might be
>>> too much worrying.
>>>
>>> Can someone explain in non juridical words what it means.
>>>
>>> I was particularly worried by the copyright license terms.
>>>
>>> "Grant of Copyright License. Subject to the terms and conditions of this
>>> Agreement, You hereby grant to Google and to recipients of software
>>> distributed by Google a perpetual, worldwide, non-exclusive, no-charge,
>>> royalty-free, irrevocable copyright license to reproduce, prepare derivative
>>> works of, publicly display, publicly perform, sublicense, and distribute
>>> Your Contributions and such derivative works."
>>>
>>> For what I understand it goes further than BSD licensing, for example it
>>> doesn't imply that the BSD copyright notice must stay in code source and
>>> along with binary distribution.
>> I'm not sure I understand exactly what you are asking.  The copyright
>> license agreement, which you sign if you want to contribute code to
>> the Go project, is not the same as the BSD license, which is the
>> license used for the Go distribution.  We explicitly don't want every
>> contributor to produce their own version of the BSD license; we want
>> all the code to be distributed under the copyright of "The Go
>> Authors."
>>
>> It is true that if you sign the CLA and give the code to Google that
>> Google could then re-release the code under a license other than the
>> BSD license.  There is no reason for Google to do that, but it would
>> be permitted to do so.  But that is not significantly different from
>> what the BSD license permits anyhow.  The BSD license, unlike, say,
>> the GPL, permits additional restrictions to be placed on the code.
>> The only relevant difference between the CLA and using the BSD license
>> yourself is that Google could distribute the code while omitting the
>> BSD license entirely.  Do you find that to be troublesome?
>>
>> Ian
>>
> Yes I found very troublesome that google has the right to omit BSD license 
> entirely by doing that it has rights that other contributors don't have.
> They have also the right to totally replace it by their license of choice

What specific rights are you concerned about?

The BSD license already allows everyone to add additional
restrictions, provided that they do not actually remove the BSD
license.  So, yes, contributing code under the CLA would permit Google
to take your code and distribute it with additional restrictions and
also without the BSD license used by the Go project.  That is a
change, but it does not seem to me to be a change that actually
matters.

The reason that Google writes the CLA in this way is so that people
can sign a single CLA in order to contribute to any Google project.
Google has many free software projects under different licenses.  It's
simpler for most people, and certainly simply for the project
developers, if people sign a single CLA, rather than to sign a
separate CLA for each project.


>> We explicitly don't want every
>> contributor to produce their own version of the BSD license; we want
>> all the code to be distributed under the copyright of "The Go
>> Authors."
>
> The point of using the go license as it is stated is to guarantee that by 
> reusing the code, contributors can't produce their own version of BSD license.

That isn't what I said, and it's not what I meant.  Contributors can
make their own copy of the Go code and add their own license.  What I
meant is that the Go distribution itself, the one that we distribute
on golang.org, comes with a single license.  Once someone has a copy
of that code, there is nothing preventing them from distributing it
under a different license, as long as they also keep a copy of the BSD
license.

> The fact it will be distributed under this terms is pretty much guaranteed 
> for all distribution except precisely the distribution made by google.

That is true in the limited sense that any distribution starting from
golang.org has to keep a copy of the Go license, whereas Google would
be permitted to make a distribution without a copy of the Go license.
But that is not a big difference, since the Go license does not
prohibit additional restrictions.

> It looks like a huge contradiction in your speech.

I'm sorry, I don't see the contradiction.


> As long as CLA is necessary for google to have additionnal guarantee about 
> patent free contributions or different thing like that I would understand, 
> but giving them the right to arbitrary license beyond what already generously 
> allow the BSD license for the code I wrote under unknown condition is hard to 
> understand for me.

I think this will be clearer once you understand that the BSD license
does not proh

[go-nuts] Re: [ANN] Mutagen - A unique file sync utility in Go inspired by Unison

2017-01-05 Thread wilk
On 05-01-2017, Shawn Milochik wrote:
> --94eb2c1a09e43b9d8205455b0873
> Content-Type: text/plain; charset=UTF-8
>
> I really like the idea of what you have here. I'm currently using SyncThing
> for this purpose. SyncThing seems to fit all your requirements with the
> exception of only needing to be installed on one of the machines. However,
> in return SyncThing allows you to select which folders are shared from each
> machine to each other machine, making it really useful for sharing only a
> subset of your data with other people. https://syncthing.net/

The bonus of syncthing is also deduplication on whole files right ?
Mutagen will do it also ?



-- 
William

-- 
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] fmt verb to single quote text

2017-01-05 Thread bsr
Alexander. thank you very much for helping out. 
your program does output my desired string, but value is read from parsing 
struct comment and not sure how to get the same effect of multi line string 
`hello ... \n world`
In other word, my input is "hello ... \n world" and not sure how to convert 
to support multi line string like `hello ... \n world`
thanks in advance,
bsr.



On Thursday, January 5, 2017 at 11:52:39 AM UTC-5, Alexander Kapshuk wrote:
>
> On Thu, Jan 5, 2017 at 6:45 PM, bsr > 
> wrote: 
> > Please see the example https://play.golang.org/p/SeG7oO5Us0 
> > 
> > I am doing some javascript codegen and I want my values single quoted. 
> so, 
> > in the above example, I want the output to be 
> > 
> > 
> > { v: 'hello ... \n world'} 
> > 
> > 
> > instead of 
> > 
> > { v: '"hello ... \n world"'}  or { v: "hello ... \n world"} 
> > 
> > how can I do that? 
> > 
> > thanks, 
> > bsr. 
> > 
> > -- 
> > 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. 
>
> https://play.golang.org/p/GEQpdi6C6s 
>

-- 
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] fmt verb to single quote text

2017-01-05 Thread Matthew Singletary
If you are using it in a fmt string (like your example), you can use the
'%q' formatting verb (like this example
).



On Thu, Jan 5, 2017 at 11:45 AM bsr  wrote:

Please see the example https://play.golang.org/p/SeG7oO5Us0

I am doing some javascript codegen and I want my values single quoted. so,
in the above example, I want the output to be


{ v: 'hello ... \n world'}


instead of

{ v: '"hello ... \n world"'}  or { v: "hello ... \n world"}

how can I do that?

thanks,
bsr.

-- 
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] fmt verb to single quote text

2017-01-05 Thread Alexander Kapshuk
On Thu, Jan 5, 2017 at 6:45 PM, bsr  wrote:
> Please see the example https://play.golang.org/p/SeG7oO5Us0
>
> I am doing some javascript codegen and I want my values single quoted. so,
> in the above example, I want the output to be
>
>
> { v: 'hello ... \n world'}
>
>
> instead of
>
> { v: '"hello ... \n world"'}  or { v: "hello ... \n world"}
>
> how can I do that?
>
> thanks,
> bsr.
>
> --
> 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.

https://play.golang.org/p/GEQpdi6C6s

-- 
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] fmt verb to single quote text

2017-01-05 Thread bsr
Please see the example https://play.golang.org/p/SeG7oO5Us0

I am doing some javascript codegen and I want my values single quoted. so, 
in the above example, I want the output to be


{ v: 'hello ... \n world'}


instead of

{ v: '"hello ... \n world"'}  or { v: "hello ... \n world"}

how can I do that?

thanks,
bsr.

-- 
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] [JOB] Intermediate/Senior Developer at OneConfig

2017-01-05 Thread Charl Matthee
Unfortunately not.


On Thu, 05 Jan 2017 at 17:18 Nyah Check  wrote:

> Can you work remotely?
>
>
> On Jan 3, 2017 1:20 PM, "Charl Matthee"  wrote:
>
> Hi,
>
> OneConfig is in the process of growing our technical team and looking for
> some intermediate/senior Go developers in Cape Town, South Africa.
>
> *About Us*
>
> At OneConfig we simplify the complicated and expensive processes around
> managing, monitoring and providing insightful reporting for Junos devices.
>
> *Responsibilities*
>
> * Plan, design and develop new features and improvements of the OneConfig
> platform.
> * Improve the visibility (monitoring/tracing), availability, latency,
> security and scalability of backend services.
> * Produce high quality, maintainable code with great test coverage.
> * Make intelligent choices for the adoption of new technologies based on
> your extensive experience.
> * Do code reviews and help other developers to improve our code.
> * Independently work on analysis, development and testing.
> * Solve problems relating to mission critical services and build
> automation to prevent problem recurrence/regression.
> * Actively influence the designs and architectures for distributed systems
> and micro services.
> * Work with internal/external teams of developers and other stakeholders
> across multiple time-zones.
>
> *Minimum Requirements*
>
> * BS degree in Computer Science or equivalent, demonstrable practical
> experience.
> * Minimum 5 years of Go programming experience (for
> network/distributed/analytics services).
> * Minimum 7 years of programming experience with languages like C/C++,
> Haskell, Ruby or Python (at least one).
> * Experience in developing and maintaining fast, scalable and
> well-documented APIs.
> * In-depth experience with one or more of JSON, MsgPack and XML.
> * Good practices documenting, writing and maintaining clean code.
> * Solid understanding of Networking.
> * Able to design data models for RDBMSs like MySQL or PostgreSQL as well
> as for any kind of NoSQL data store including MongoDB, Redis and others.
> * Very good knowledge of Linux/UNIX server operating systems and strong
> systems-level debugging skills.
> * In-depth experience with one or more of AWS, Google Cloud Services,
> Rackspace or DigitalOcean.
> * Very good knowledge of Git.
> * Self motivated and able to take initiative.
> * Work comfortably alone and as part of a team.
> * Excellent verbal and written English communication skills.
>
> *Preferred Requirements*
>
> * Experience with distributed systems and resilience patterns as well as
> implementing them.
> * Understanding of processes, threads, concurrency issues, locks and Linux
> performance monitoring.
> * Strong problem solving skills; understanding/application of algorithms
> and complexity analysis.
> * Expertise in designing, implementing and monitoring micro service
> architectures.
> * Track record of Open Source contributions.
>
> If you are interested or know of anyone who might be interested please
> head over to https://www.indeed.co.za/Oneconfig-jobs to apply or require
> more information.
>
>
> Ciao
>
> Charl
>
>
>
>
>
>
>
>
>
> --
>
>
>
> 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: golang-beginners channel?

2017-01-05 Thread Marcus Franke
Hi,

You should join the gophers slack. There is a golang-newbies channel.



pacninja  schrieb am Do., 5. Jan. 2017, 16:28:

> I'm in if someone starts the channel.
>
>
> On Thursday, January 5, 2017 at 11:44:16 AM UTC+5:30, Jason E. Aten wrote:
>
> I noticed that rust has a rust-beginners irc channel. That seems like a
> very welcoming idea
>
>

-- 
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] [ANN] Mutagen - A unique file sync utility in Go inspired by Unison

2017-01-05 Thread Shawn Milochik
I really like the idea of what you have here. I'm currently using SyncThing
for this purpose. SyncThing seems to fit all your requirements with the
exception of only needing to be installed on one of the machines. However,
in return SyncThing allows you to select which folders are shared from each
machine to each other machine, making it really useful for sharing only a
subset of your data with other people. https://syncthing.net/

If you're familiar with SyncThing (or if not, it's kind of like
Dropbox/btsync but without a middleman or closed-source protocols), what's
the case for using mutagen instead of (or as well as) SyncThing?

Thanks for sharing!

Shawn

-- 
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] Facing linker issues while cross-compiling from Ubuntu/amd64 to darwin/amd64

2017-01-05 Thread Ian Lance Taylor
On Thu, Jan 5, 2017 at 5:42 AM, Kedar Babar  wrote:
>
> I had written a small go program, which refers the 'C' code, following
> is the snippet
>
> package main
>
> /*
> #include 
> */
> import "C"
> import "fmt"
>
> const cgoAddrInfoFlags = (C.AI_CANONNAME | C.AI_V4MAPPED | C.AI_ALL) &
> C.AI_MASK
>
> func main() {
> fmt.Println("Hello")
> }
>
> When i build the above program, i get the below linking errors for the
> target darwin/amd64.
> /usr/lib/go-1.6/pkg/tool/linux_amd64/link: running o64-clang failed: exit
> status 1
> ld: warning: ignoring file /tmp/go-link-601229876/01.o, file was built
> for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00
> 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being
> linked (x86_64): /tmp/go-link-601229876/01.o
> Undefined symbols for architecture x86_64:
>   "__cgo_wait_runtime_init_done", referenced from:
>   _callbackTrampoline in 00.o
>   _stepTrampoline in 00.o
>   _doneTrampoline in 00.o
>   "_x_cgo_free", referenced from:
>   __cgo_free in go.o
>   "_x_cgo_init", referenced from:
>   __cgo_init in go.o
>   "_x_cgo_malloc", referenced from:
>   __cgo_malloc in go.o
>   "_x_cgo_notify_runtime_init_done", referenced from:
>   __cgo_notify_runtime_init_done in go.o
>   "_x_cgo_setenv", referenced from:
>   runtime._cgo_setenv in go.o
>   "_x_cgo_thread_start", referenced from:
>   __cgo_thread_start in go.o
>   "_x_cgo_unsetenv", referenced from:
>   runtime._cgo_unsetenv in go.o
> ld: symbol(s) not found for architecture x86_64
> clang: error: linker command failed with exit code 1 (use -v to see
> invocation)
>
> Following is the go command used to build the above stuff.
> env CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=o64-clang go build -x -work
> -ldflags="-extld=o64-clang"

I don't know what the problem is, but the first step is to look at the
direct invocations of the C compiler in the `go build -x` output and
make sure that they look right.  Make sure that nothing is calling
"gcc" directly.  Make sure that the invocations of "o64-clang" have
any required flags.

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] Facing linker issues while cross-compiling from Ubuntu/amd64 to darwin/amd64

2017-01-05 Thread Kedar Babar
Hi,
I had written a small go program, which refers the 'C' code, following 
is the snippet

package main

/*
#include 
*/
import "C"
import "fmt"

const cgoAddrInfoFlags = (C.AI_CANONNAME | C.AI_V4MAPPED | C.AI_ALL) & 
C.AI_MASK

func main() {
fmt.Println("Hello")
} 

When i build the above program, i get the below linking errors for the 
target darwin/amd64.
/usr/lib/go-1.6/pkg/tool/linux_amd64/link: running o64-clang failed: exit 
status 1
ld: warning: ignoring file /tmp/go-link-601229876/01.o, file was built 
for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00 
0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being 
linked (x86_64): /tmp/go-link-601229876/01.o
Undefined symbols for architecture x86_64:
  "__cgo_wait_runtime_init_done", referenced from:
  _callbackTrampoline in 00.o
  _stepTrampoline in 00.o
  _doneTrampoline in 00.o
  "_x_cgo_free", referenced from:
  __cgo_free in go.o
  "_x_cgo_init", referenced from:
  __cgo_init in go.o
  "_x_cgo_malloc", referenced from:
  __cgo_malloc in go.o
  "_x_cgo_notify_runtime_init_done", referenced from:
  __cgo_notify_runtime_init_done in go.o
  "_x_cgo_setenv", referenced from:
  runtime._cgo_setenv in go.o
  "_x_cgo_thread_start", referenced from:
  __cgo_thread_start in go.o
  "_x_cgo_unsetenv", referenced from:
  runtime._cgo_unsetenv in go.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see 
invocation)

*Following is the go command used to build the above stuff.*
env CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC=o64-clang go build -x -work 
-ldflags="-extld=o64-clang"



-- 
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: golang-beginners channel?

2017-01-05 Thread pacninja
I'm in if someone starts the channel.

On Thursday, January 5, 2017 at 11:44:16 AM UTC+5:30, Jason E. Aten wrote:
>
> I noticed that rust has a rust-beginners irc channel. That seems like a 
> very welcoming idea.
>
> ~~~
>
> The most important community resources for those new to Rust are:
>
>- #rust-beginners 
>
> , 
>an IRC channel that loves answering questions at any depth.
>
> ~~~
>
> How about a new golang-beginners channel?
>

-- 
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] [ANN] Mutagen - A unique file sync utility in Go inspired by Unison

2017-01-05 Thread Jacob Howard
Greetings fellow Gophers!

I wanted to share and get feedback on a Go project that I've been working 
on for a little while called Mutagen:

Usage information: https://havoc-io.github.io/mutagen/
Source: https://github.com/havoc-io/mutagen

It's a continuous, bidirectional file synchronization utility similar to 
Unison  (think SSHFS, but far 
more robust and not requiring kernel extensions). It's main goal is 
simplicity - no configuration, no flags, just usage (a minimal number of 
knobs to turn, in Go parlance).

It uses Go's unique abilities to enable what I consider to be its most 
interesting feature: It only needs to be installed on the system where you 
want to control synchronization. It uses Go's cross-compiling support and 
syscall-only binaries to create small "agent" binaries that it copies to 
remote hosts automatically after probing for their OS/architecture. It 
supports a broad range of platforms - pretty much anything Go supports 
except Plan 9 and mobile (mostly just because those ports can be a bit 
flakey).

The original goal was to mirror and work with code on smaller platforms 
(e.g. a Raspberry Pi) on which you might want to compile and run (but not 
write) code, thus saving you the need to either transfer your vim/emacs 
configuration over to remote systems or push/pull from your local system 
every time you want to test a change. But you can use it for general 
synchronization as well.

You can find a full accounting of the features here: 
https://github.com/havoc-io/mutagen#unique-features

The *tl;dr* is: user-space (no kernel extensions or admin privileges 
needed), syncs locally or over SSH (can even sync SSH-to-SSH without a 
local copy of files), auto-reconnects, uses pipelined rsync algorithm for 
any significant data transfer to make effective use of bandwidth and reduce 
latency, can handle very large directories (the Linux source tree was the 
development case), identifies conflicts, handles platform and filesystem 
quirks, and has dynamic status display.

*I'd be particularly interested in feedback regarding the idea, design, and 
usefulness to people.* The code is clean, but not all exported members are 
currently documented because I was sort of treating it like one giant 
internal package. This will be fixed soon though. I'll also provide full 
documentation of the algorithm in the near future, but it's very similar to 
Unison, so the design documents for that will give you 95% of the idea.

It's still an early beta, though essentially feature complete. I've only 
tested it personally between macOS, Windows (XP/7), and Linux 
(386/amd64/ARM). I'd be interested in tests on more obscure systems 
(non-x86 architectures and some of the BSDs), but please be aware that it 
is a beta that has the power to create and delete files, so it's not to be 
used on production or mission-critical systems, and could be dangerous on 
any system.

This is my first medium-to-large Go project.  On the whole it was a 
positive experience, and I'm fairly certain that this exact design would be 
almost impossible to reproduce with any other language on the market right 
now.  It also uses a fair number of excellent Go libraries (see legal.go in 
the source), so thanks to all those authors and the Go team for making it 
possible.

-Jacob

-- 
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] [JOB] Intermediate/Senior Developer at OneConfig

2017-01-05 Thread Nyah Check
Can you work remotely?
On Jan 3, 2017 1:20 PM, "Charl Matthee"  wrote:

> Hi,
>
> OneConfig is in the process of growing our technical team and looking for
> some intermediate/senior Go developers in Cape Town, South Africa.
>
> *About Us*
>
> At OneConfig we simplify the complicated and expensive processes around
> managing, monitoring and providing insightful reporting for Junos devices.
>
> *Responsibilities*
>
> * Plan, design and develop new features and improvements of the OneConfig
> platform.
> * Improve the visibility (monitoring/tracing), availability, latency,
> security and scalability of backend services.
> * Produce high quality, maintainable code with great test coverage.
> * Make intelligent choices for the adoption of new technologies based on
> your extensive experience.
> * Do code reviews and help other developers to improve our code.
> * Independently work on analysis, development and testing.
> * Solve problems relating to mission critical services and build
> automation to prevent problem recurrence/regression.
> * Actively influence the designs and architectures for distributed systems
> and micro services.
> * Work with internal/external teams of developers and other stakeholders
> across multiple time-zones.
>
> *Minimum Requirements*
>
> * BS degree in Computer Science or equivalent, demonstrable practical
> experience.
> * Minimum 5 years of Go programming experience (for
> network/distributed/analytics services).
> * Minimum 7 years of programming experience with languages like C/C++,
> Haskell, Ruby or Python (at least one).
> * Experience in developing and maintaining fast, scalable and
> well-documented APIs.
> * In-depth experience with one or more of JSON, MsgPack and XML.
> * Good practices documenting, writing and maintaining clean code.
> * Solid understanding of Networking.
> * Able to design data models for RDBMSs like MySQL or PostgreSQL as well
> as for any kind of NoSQL data store including MongoDB, Redis and others.
> * Very good knowledge of Linux/UNIX server operating systems and strong
> systems-level debugging skills.
> * In-depth experience with one or more of AWS, Google Cloud Services,
> Rackspace or DigitalOcean.
> * Very good knowledge of Git.
> * Self motivated and able to take initiative.
> * Work comfortably alone and as part of a team.
> * Excellent verbal and written English communication skills.
>
> *Preferred Requirements*
>
> * Experience with distributed systems and resilience patterns as well as
> implementing them.
> * Understanding of processes, threads, concurrency issues, locks and Linux
> performance monitoring.
> * Strong problem solving skills; understanding/application of algorithms
> and complexity analysis.
> * Expertise in designing, implementing and monitoring micro service
> architectures.
> * Track record of Open Source contributions.
>
> If you are interested or know of anyone who might be interested please
> head over to https://www.indeed.co.za/Oneconfig-jobs to apply or require
> more information.
>
>
> Ciao
>
> Charl
>
> --
> 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] code gen off a golang template --> a data binding struct ?? Anyone found a library that can do this..

2017-01-05 Thread Joe Blue
Hey all !!

I have been googling for this, and wondering if i should try and write 
something to specifically do this.

Here is the idea...

There are lots of awesome libraries out there to help me code gen from a 
struct to lots of other things.
But i need the ability to code gen from a standard golang template --> a 
struct that can encapsulate the data that the template needs ?
This seems really useful for me for lots of things.
I could then code gen off the template to a struct (as part of my build) , 
and if the template changes (could be a myriad of reasons), then I will get 
a compile error, rather than a runtime error. I want compile time errors of 
course for me, and my CI.

Other examples:
- Got lots and lots of email templates or JSON templates that others are 
working up and need to bind to them ?
- Talking to third party SOAP servers ? Just sniff the text over the wire, 
copy it into a golang template, work out what in it needs to be changeable, 
and then code gen a struct to use it.
then just pipeline many together.
- Heaps of other examples of course.


Please let me know your thoughts.
If i am taking the wrong approach feel free to object and steer me 




-- 
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: Accessing an slice is too slow than Array

2017-01-05 Thread Uli Kunitz
A few comments:

For such microbenchmarks you need to check the assembler for optimizations. 
The C code probably removed the complete loop.

The Go version and machine architecture is relevant. There were significant 
changes recently, particular with the introduction of SSA (static single 
assignment) for amd64.

Usally for _, x := range  is much faster than direct access. 

The difference between array and slice is probably that the slice access 
must read the pointer to the backing array before the actual value can be 
accessed. This step is not required for arrays.

-- 
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: How to pass a go file name as arguments to go run

2017-01-05 Thread bsr
thanks Dave. This is to test a code generation utility during development, 
so not to build/install etc, but run directly. thanks again for your help.

On Thursday, January 5, 2017 at 12:07:55 AM UTC-5, Dave Cheney wrote:
>
>  go run cmd/main.go -- tests/a/in.go
>
> But you've probably reached the practical limit of what go run should be 
> used for. I recommend using the expected GOPATH package layout, go 
> build/install, etc.
>
> On Thursday, 5 January 2017 16:02:50 UTC+11, bsr wrote:
>>
>> Following works.
>>
>> go run cmd/main.go tests/a/in
>>
>>
>> flag.Parse()
>> args := flag.Args()
>> //args ->  []string{"tests/a/in"}
>>
>> but when I do
>>  
>>
>> go run cmd/main.go tests/a/in.go
>>
>> named files must all be in one directory; have cmd/ and tests/a/
>>
>>
>> I am not trying to build both files, but "tests/a/in.go: is an argument 
>> to the built program at cmd/main.go
>>
>>
>> tried like
>>
>>
>> go run cmd/main.go "tests/a/in.go" , but same error.
>>
>>
>> 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] Re: How to use ~/ in terminal with go program?

2017-01-05 Thread Aurélien DESBRIÈRES
Thanks a lot!

On Thu, Jan 5, 2017 at 11:32 AM Konstantin Khomoutov <
flatw...@users.sourceforge.net> wrote:

> On Thu, 5 Jan 2017 02:09:24 -0800 (PST)
> Aurélien Desbrières  wrote:
>
> > Vendor?? you mean I have to pay to write software? I have to pay to
> > use a lib?
>
> I suppose you were actually trying to reply to this remark by Ian
> Davis:
>
> > Vendor the library using Go's vendoring support. Then you will always
> > have a copy of the code you need.
>
> Well, this is just a terminology issue.  "Vendoring" is a term
> colloquially used to mean integrating 3rd-party code required by your
> own project into your project -- in a special way.
>
> Since version 1.5 Go has minimal native support for vendoring by giving
> a special treatment to a directory named "vendor" located right under
> the top-level directory of a Go project: when building, the Go compiler
> first tries to locate the package your code imports in that directory.
>
> This means, you can take any external library, place its source code
> under the directory named "vendor" in your project and just keep it
> there (and check it into the version control system you're using).
>
> Note that vendoring has both strong and weak qualities--just like any
> other approach to depending on a 3rd-party software.  Heaps and heaps
> of words were written on this topic so I won't repeat them.
> Just google for golang+vendoring and see what's written about this.
>
> Several related notes:
>
> * When writing production code, you have to check the licenses of the
>   libraries you intend to vendor: they must be compatible with the way
>   your code is licensed (or used/deployed -- if it's for private use).
>
> * There's nothing wrong for paying for a 3rd-party library
>   even though we're supposedly discussing F/OSS now ;-)
>
> [...]
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: How to use ~/ in terminal with go program?

2017-01-05 Thread Konstantin Khomoutov
On Thu, 5 Jan 2017 02:09:24 -0800 (PST)
Aurélien Desbrières  wrote:

> Vendor?? you mean I have to pay to write software? I have to pay to
> use a lib?

I suppose you were actually trying to reply to this remark by Ian
Davis:

> Vendor the library using Go's vendoring support. Then you will always
> have a copy of the code you need.

Well, this is just a terminology issue.  "Vendoring" is a term
colloquially used to mean integrating 3rd-party code required by your
own project into your project -- in a special way.

Since version 1.5 Go has minimal native support for vendoring by giving
a special treatment to a directory named "vendor" located right under
the top-level directory of a Go project: when building, the Go compiler
first tries to locate the package your code imports in that directory.

This means, you can take any external library, place its source code
under the directory named "vendor" in your project and just keep it
there (and check it into the version control system you're using).

Note that vendoring has both strong and weak qualities--just like any
other approach to depending on a 3rd-party software.  Heaps and heaps
of words were written on this topic so I won't repeat them.
Just google for golang+vendoring and see what's written about this.

Several related notes:

* When writing production code, you have to check the licenses of the
  libraries you intend to vendor: they must be compatible with the way
  your code is licensed (or used/deployed -- if it's for private use).

* There's nothing wrong for paying for a 3rd-party library
  even though we're supposedly discussing F/OSS now ;-)

[...]

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: How to use ~/ in terminal with go program?

2017-01-05 Thread Aurélien Desbrières
Vendor?? you mean I have to pay to write software? I have to pay to use a 
lib?


On Thursday, January 5, 2017 at 8:19:21 AM UTC+1, Konstantin Khomoutov 
wrote:
>
> On Tue, 3 Jan 2017 00:00:27 -0800 (PST) 
> Caleb Doxsey > wrote: 
>
> > What's wrong with a library? 
> > 
> > This particular library is used by vagrant and dozens of other 
> > software projects, it's cross platform and handles all the edge cases. 
> > 
> > Never relying on 3rd party libraries is a very inefficient way to 
> > write software. Seems like even just copying the code would be more 
> > productive than writing it from scratch. It has a very permissive 
> > license: https://github.com/mitchellh/go-homedir/blob/master/LICENSE. 
> [...] 
>
> To be honest, the implementation of that library is rather naive. 
> For some reason, it doesn't use Go's built-in features but resorts fo 
> calling out /usr/bin/getent on non-Darwin POSIX systems.  The author 
> explains their point in the README but I, for one, do not buy into 
> their reasoning completely (because I have no use for/of Macs). 
>
> All-in-all, the point everyone ignores is that why the OP wanted to do 
> tilde expansion by hand? ;-)  It appears, that they were implementing a 
> cat-like program which for some reason would *ask* the user to input 
> the name of the file to cat -- interactively.  I'd say this goes 
> against the Unix command-line usage paradigms.  That is, it's okay as 
> a programming exersize but otherwise is actively harmful for any 
> production-usage code I may envision. 
>
> And since this is a programming exersize, I think it's okay of the OP 
> would exersize theirselves more, and write the necessary code by hand. 
>
> Well, the proplem is that instead of researching the topic they have 
> just asked for a ready-made solution. 
> Exactly as nailed down in the famous . 
>

-- 
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] Google Grumpy (Python->Go)

2017-01-05 Thread Justin Israel
I just gave this a play since I was really curious what it could do. But it
seems like of your python module has imports for other python modules, they
get transpiled into Go import statements that look at the grumpy stdlib
location. Does anyone have any information on the extend of the support,
besides the documented caveats?

>From what I gather, it seems to target the use case of single file
executable scripts, in pure python, with only dependencies on the python
stdlib or the Go stdlib, and use multithreading as a focus (in order for it
to realize the performance benefits). Does that seem correct? If so, can
anyone explain a real or hypothetical example of where grumpy is most
useful? I can't say I have anything that fits this use case. But I suppose
google/YouTube team have a bunch of these concurrent data crunching
scripts.

Justin


On Thu, Jan 5, 2017, 10:54 AM andrey mirtchovski 
wrote:

> > It’s also about 2x slower than the original Python. All of this
> indirection is necessary to preserve the dynamic semantics of Python.
> Basically it’s taking the calls into the runtime that a Python interpreter
> would make, and writing them out one after another.
>
> this single-thread slowdown does appear on the performance graph
> published in the article. python historically has had significant
> effort thrown behind single-thread/process performance.
>
> --
> 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] Accessing an slice is too slow than Array

2017-01-05 Thread P Q
I measured how long it takes to access an element on array in three ways: 
array, slice, unsafe.Pointer

https://play.golang.org/p/Ofz3u8_AZe

BenchmarkArray  : 500025.7 ns/op
BenchmarkSlice  : 200059.1 ns/op
BenchmarkPointer: 3 6.85 ns/op
BenchmarkC  : 20 0.00 ns/op

I know array and slice is relatively slow as they checks for an index to be 
out of bounds when accessing, but I am astounding that there is the huge 
difference between array and slice. Can you explain or give me some link 
about 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.