[go-nuts] Fixing the version of protoc-gen-go

2018-03-23 Thread Timothy Raymond
I've been running protoc and protoc-gen-go in a container (and fixing versions 
by checking out commits) to try to address this problem for my projects. I'd 
love to hear what others have done though.

-- 
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] implementation for GetsockoptLinger() and GetsockoptTimeval()

2018-03-23 Thread Ian Lance Taylor
On Fri, Mar 23, 2018 at 3:43 PM, yuxuanli via golang-nuts
 wrote:
>
> I am using the x/sys/unix package to get the socket options of a fd. While
> there are SetsockoptLinger() and SetsockoptTimeval() for setting the Linger
> and Timeout options, there is no corresponding getter for them. I wonder if
> there's another preferable way to get the socket option info I want, or a
> getter addition is needed. Thanks!

Seems like we should add getters.  Could you open an issue at
https://golang.org/issue?  Thanks.

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] implementation for GetsockoptLinger() and GetsockoptTimeval()

2018-03-23 Thread yuxuanli via golang-nuts
Hi,

I am using the x/sys/unix package 
to get the socket options of a fd. While there are SetsockoptLinger() 
and SetsockoptTimeval() for setting the Linger and Timeout options, there 
is no corresponding getter for them. I wonder if there's another preferable 
way to get the socket option info I want, or a getter addition is needed. 
Thanks!

Best,
Yuxuan

-- 
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] Copy a slice to new memory adresses

2018-03-23 Thread Alex Efros
Hi!

On Fri, Mar 23, 2018 at 12:10:55PM -0700, Alex Dvoretskiy wrote:
> For example, I have a multidimensional slice, which I want to modify, but 
> keep an original slice untouched.
> 
> Do I need to do this all the time or there is another convenient way to do 
> this?:
> 
> https://play.golang.org/p/YDn6ii52oOt

Yes. It can be simplified with help of copy() to this:
https://play.golang.org/p/AsS7RaOPwOm

Also there are 3rd-party packages for making "deep copy", but my guess is
they will be less effective in your use case.

In case you mostly need to change just one value then you may consider
avoid copying slices which won't be modified, i.e. create function to
change one value and have it copy just one modified slice (plus parent
slice, of course).

-- 
WBR, Alex.

-- 
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] Copy a slice to new memory adresses

2018-03-23 Thread Alex Dvoretskiy
Hello Golang nuts,

For example, I have a multidimensional slice, which I want to modify, but 
keep an original slice untouched.

Do I need to do this all the time or there is another convenient way to do 
this?:

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


Thanks
Alex

-- 
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] Fixing the version of protoc-gen-go

2018-03-23 Thread amit . chandak
Hi,
   I am using dep for version management. I need to have the following 
protoc plugin.

go get -u github.com/golang/protobuf/protoc-gen-go
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger

The way i understand 'go get' is it gets the latest from tree/master. 
However, i want to fix on the version, rather than getting the latest. 

Can i use 'go install' instead and make it use the vendor directory 
protoc-gen-go version? If yes, how to make 'go install' use that directory, 
i tried

Amits-MacBook-Pro:api achandak$ go install -pkgdir 
vendor/github.com/golang/protobuf/protoc-gen-go protoc-gen-go
can't load package: package protoc-gen-go: cannot find package 
"protoc-gen-go" in any of:
/usr/local/Cellar/go/1.9.3/libexec/src/protoc-gen-go (from $GOROOT)
/Users/achandak/workspace/src/protoc-gen-go (from $GOPATH)

Its still looking at /Users/achandak/workspace/src

Any help is greatly appreciated.

Thanks
Amit

-- 
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] Is there any way to define a struct member to hold a generic type channel?

2018-03-23 Thread matthewjuran
An empty interface var can hold any type, so you could have a chan interface{} 
then use an interface type assertion when you read a value.

Matt

-- 
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: Is there any way to define a struct member to hold a generic type channel?

2018-03-23 Thread prades . marq
No, go does not have generics.

chan int is not the same type as chan string for instance and you cannot 
declare a type that hold all types of channel unless you resort to 
"interface {}" AND runtime reflection.

Le jeudi 22 mars 2018 16:25:39 UTC-10, 刘焱 a écrit :
>
> I'm trying to define a Reference Counted Channel struct, like below:
>
> type RefCountedChannel {
> Channel chan Type
> RefCount int
> mux sync.Mutex
> }
>
> I have to define different struts to hold different channel types.
> But I don't care the type of Channel, I just close is when RefCount become 
> 0.
> May I use a single Channel to hold all types of channels?
>

-- 
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] Is there any way to define a struct member to hold a generic type channel?

2018-03-23 Thread liuyain
I'm trying to define a Reference Counted Channel struct, like below:

type RefCountedChannel {
Channel chan Type
RefCount int
mux sync.Mutex
}

I have to define different struts to hold different channel types.
But I don't care the type of Channel, I just close is when RefCount become 
0.
May I use a single Channel to hold all types of channels?

-- 
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: Go 1.10: how should I pass linker flags scoped to a single vendored package?

2018-03-23 Thread shah via golang-nuts
Luke got it right; as it turns out, this is the same bug as 
https://github.com/golang/go/issues/24456 

.

On Wednesday, March 21, 2018 at 12:58:37 PM UTC-7, lre...@uber.com wrote:
>
> On Tuesday, March 20, 2018 at 3:16:20 PM UTC-7, Akshay Shah wrote:
>>
>> Like many folks, I often embed version information (git hash, build time, 
>> etc) into Go binaries with linker flags. Before Go 1.10, this worked:
>>
>> go build -ldflags="-X 
>> github.com/user/top_level_project/vendor/github.com/user/version.Version=some_hash"
>>  github.com/user/top_level_project
>>
>> After Go 1.10, I’m having trouble amending this approach in a way that 
>> only busts the build cache for the vendored version package.
>>
>> go build -ldflags=all="-X 
>> github.com/user/top_level_project/vendor/github.com/user/version.Version=some_hash"
>>  github.com/user/top_level_project
>>
>> works, but rebuilds much more than necessary. A variety of alternatives 
>> to =all= haven’t worked as I expected.
>>
>> I’ve put together a small reproduction and a script showing the different 
>> approaches I’ve tried at github.com/akshayjshah/golink. Any suggestions 
>> would be very welcome!
>>
>> Cheers,
>> Akshay
>>
> Looks like this works:
>
> diff --git a/demo.sh b/demo.sh
> index 888a5df..83ab264 100644
> --- a/demo.sh
> +++ b/demo.sh
> @@ -36,3 +36,6 @@ demo
>
>
>  SCOPE="github.com/akshayjshah/golink/vendor/..."
>  demo
> +
> +SCOPE="github.com/akshayjshah/golink"
> +demo
>
> I can't tell if this intentional though. I'm also exploring this problem 
> in https://github.com/golang/go/issues/24456
>
> - Luke 
>
>> ​
>>
>

-- 
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] godoc.org graph default view shows huge graph even for smalli packages

2018-03-23 Thread fgergo
Hi,
 iirc earlier (years ago?) when on godoc.org I clicked "Package main
imports N packages (graph)" only non-standard dependencies were shown.
Now all dependencies are shown for the currently shown package graph.
When I click "Hide" on the graph page even then standard packges are
shown.
Do I remember correctly that the default graph view was more terse earlier?
Is this the intended behavior?
thanks,
Gergely Födémesi

-- 
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] A golang source code query language

2018-03-23 Thread Forud A
Hello, 

GoQL  is a hubby project of mine, for 
extracting global var/func/const/type from go source code using simple sql. 
the project is in early stage and any contribution/advice is welcome!

A Clumsy :) Demo (asscinema) https://asciinema.org/a/170483
https://github.com/fzerorubigd/goql

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] Known unknown escape sequence in Go

2018-03-23 Thread Lutz Horn
> I'm trying with simple Perl character class regular expression, which 
> should be supported by Go (link) 
[...]
> and I found that `*\w*` or `*\S*` Perl character class are not supported. 

You must escape the backslash as '\\w' etc:

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

Lutz

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