[go-nuts] Re: Simplest way to extend the functionality of other's package

2016-06-15 Thread Tong Sun
On Thursday, June 16, 2016 at 12:11:54 AM UTC-4, Tong Sun wrote: > > Let me explain with an example, > > For goquery, most functions are of type "func (s *Selection) Xxx(selector > string) *Selection". > For e.g., "Find" is: > > func (s *Selection >

Re: [go-nuts] Re: [ANN] primegen.go: Sieve of Atkin prime number generator

2016-06-15 Thread gordonbgood
On Thursday, 16 June 2016 10:11:12 UTC+7, Nigel Tao wrote: > > On Thu, Jun 16, 2016 at 11:22 AM, > > wrote: > > it no longer does the array bounds check twice > > It's not safe, but you might want to try disabling bounds checking by > "go tool compile -B" or "go build -gcflags=-B" > In fact,

[go-nuts] Simplest way to extend the functionality of other's package

2016-06-15 Thread Tong Sun
Let me explain with an example, For goquery, most functions are of type "func (s *Selection) Xxx(selector string) *Selection". For e.g., "Find" is: func (s *Selection ) Find(selector string ) *Select

Re: [go-nuts] Seeker documentation.

2016-06-15 Thread Ian Lance Taylor
On Wed, Jun 15, 2016 at 5:43 PM, wrote: > It seems that it is not well defined what happens when you get an error. > Looking at the os.File implementation the returned n value is always zero on > error. But isn't it possible that the underlying call can error but still > have seeked some? Since

[go-nuts] goquery, how to remove child

2016-06-15 Thread Tong Sun
How to remove child nodes in goquery? I'm trying 3 different ways to remove child nodes in my sample code, https://github.com/suntong/kuaizh/blob/master/crawler/kijiji.go as I can't quite figure it out from the doc: titleHtml, _ = title.RemoveFiltered("a").Html() locationHtml, _ = location.Rem

Re: [go-nuts] Re: [ANN] primegen.go: Sieve of Atkin prime number generator

2016-06-15 Thread Nigel Tao
On Thu, Jun 16, 2016 at 11:22 AM, wrote: > it no longer does the array bounds check twice It's not safe, but you might want to try disabling bounds checking by "go tool compile -B" or "go build -gcflags=-B". -- You received this message because you are subscribed to the Google Groups "golang-

Re: [go-nuts] GoMobile window size always 800x800

2016-06-15 Thread Nigel Tao
On Fri, Jun 10, 2016 at 12:45 PM, Nigel Tao wrote: > I'd consider a patch that changed the hard-coded value to a more > phone-like aspect ratio instead of 1:1. Maybe 4:3 or 5:3 or 3:2 or > 16:9 but as you can see there are multiple bike-shedding options and > no single one is obviously 'correct'.

Re: [go-nuts] context for user credentials

2016-06-15 Thread daviswahl
That's *really *not what you're supposed to use a context for. If you just want a grab bag for random values (and really, you don't), you can just use a map. A context is for sharing scoped data across APIs, threads, and other boundaries. The documentation says "request scoped" but that term c

Re: [go-nuts] A proposal for generic in go

2016-06-15 Thread xingtao zhao
I read your proposals now. My proposal is very similar to your proposal of type parameter - in fact, they are almost identical. But in my proposal, I am not going that far as in your proposal. I did not include the operators, thus all generic functions can only access the unknown type through i

[go-nuts] Re: [ANN] primegen.go: Sieve of Atkin prime number generator

2016-06-15 Thread gordonbgood
golang version 1.7beta1 does indeed help, and the time is now not much worse than C#/Java, but still not as good as C/C++ due to the single array bounds check: Using the same procedure to obtain an assembly listing (go tool compiler -S PrimeTest.go > PrimeTest.s): line 36for j := (

[go-nuts] Seeker documentation.

2016-06-15 Thread jonathan . gaillard
It seems that it is not well defined what happens when you get an error. Looking at the os.File implementation the returned n value is always zero on error. But isn't it possible that the underlying call can error but still have seeked some? The reader and writer docs are clear :) -- You rece

Re: [go-nuts] GoMobile window size always 800x800

2016-06-15 Thread Nigel Tao
On Tue, Jun 14, 2016 at 4:53 AM, Andy Brewer wrote: > I agree that good mobile UI should be responsive. I'm thinking this feature > would be useful for testing your app on those wide range of mobile screen > sizes. Right now, it's difficult to test apps made with gomobile because the > viewport ne

Re: [go-nuts] Bitmasks on signed types

2016-06-15 Thread Nigel Tao
On Wed, Jun 15, 2016 at 6:08 AM, Dave MacFarlane wrote: > Would a patch that adds a Mult receiver function to Int52_12 and > Int26_6 be welcome in x/image/math/fixed? Yeah, I'd take that. For Int26_6, I'd convert to int64, multiply, then shift and convert back to Int26_6, as Matt Harden said. -

Re: [go-nuts] caching of cgo compilation

2016-06-15 Thread Dave Cheney
This is why I recommend go install* * There is only one place where go install is not appropriate, and that is when cross compiling ** ** when using version of Go distributed as a binary and installed in a directory that you don't have permission to write to. On Thu, Jun 16, 2016 at 9:52 AM, Hug

Re: [go-nuts] caching of cgo compilation

2016-06-15 Thread Hugh Emberson
He might be running go test which also seems to rebuild everything every time unless it has been installed. go test -i installs all the dependencies for a test and fixes this problem. On Wed, Jun 15, 2016 at 6:14 PM, Dave Cheney wrote: > My guess is you are using go build, which compiles then

Re: [go-nuts] caching of cgo compilation

2016-06-15 Thread Dave Cheney
My guess is you are using go build, which compiles then discards everything it just compiled (unless what was compiled was a main package, in which case the binary will be left in your current working directory) I recommend using go install -v rather than go build for general use. -- You rece

Re: [go-nuts] caching of cgo compilation

2016-06-15 Thread John Weldon
If you run `go install github.com/mattn/go-sqlite3/...` it'll cache that build step artifact. John Weldon m) 503-941-0825 On Wed, Jun 15, 2016 at 3:42 PM, Alex Flint wrote: > Hmm but I am also not changing the Go source of the package in question, > yet the C sources seem to get recompiled. >

Re: [go-nuts] caching of cgo compilation

2016-06-15 Thread Alex Flint
Hmm but I am also not changing the Go source of the package in question, yet the C sources seem to get recompiled. Just to make sure we're on the same page, I have two packages: mypkg and go-sqlite3, where the former is pure Go and the depends on the latter, which contains both C and Go code. When

[go-nuts] caching of cgo compilation

2016-06-15 Thread Dave Cheney
If your cgo code is in another package to the one your are changing then compilation should be cached? Are you using go build or go install? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving email

Re: [go-nuts] caching of cgo compilation

2016-06-15 Thread Ian Lance Taylor
On Wed, Jun 15, 2016 at 2:54 PM, Alex Flint wrote: > Under what conditions does a cgo package get recompiled? I am using > go-sqlite3 and it appears that the C compiler/linker is run every time I > build my project, even though I am not changing any of the C sources. I > would have expected it to

[go-nuts] [ANN] Beta Go support added in AppNeta TraceView (full stack monitoring)

2016-06-15 Thread jmoore
Hey All, We've recently released support for Golang on our APM platform. You can read our blog post here and check out our repo https://github.com/appneta/go-appneta We're really excited to bring our distributed transaction tracing platform t

[go-nuts] caching of cgo compilation

2016-06-15 Thread Alex Flint
Under what conditions does a cgo package get recompiled? I am using go-sqlite3 and it appears that the C compiler/linker is run every time I build my project, even though I am not changing any of the C sources. I would have expected it to be run once and then the results re-used, but perhaps there

[go-nuts] Re: Strange "go get" behavior

2016-06-15 Thread Vorn Mom
Thanks, that was it! On Wednesday, June 1, 2016 at 3:58:55 PM UTC-4, Vorn Mom wrote: > > I have a Go package hosted in a private git repo. The go package consists > of a parent package and two sub packages: > > github.privaterepo.com/vmom/gizbus > github.privaterepo.com/vmom/gizbus/amqp > github

[go-nuts] Diff struct

2016-06-15 Thread 'Mihai B' via golang-nuts
Is there any effort/package/lib that provides diffs on structs with serilization/deserilization methods? I need to store data changes in a db. The db itself (datastore) doesn't provide versions so I need to store the diffs by myself. Currently I'm storing complete copies but they are quite inef

Re: [go-nuts] Re: broadcasting on a set of channels

2016-06-15 Thread Eric Greer
Perfect. Thanks! On Wed, Jun 15, 2016, 12:44 PM Ian Lance Taylor wrote: > On Wed, Jun 15, 2016 at 12:25 PM, Eric Greer wrote: > > > > Thanks for the reply. What I'm trying to do is to make a web socket > server > > where all clients are sent broadcast messages. When the client connects, > a > >

Re: [go-nuts] Re: broadcasting on a set of channels

2016-06-15 Thread Ian Lance Taylor
On Wed, Jun 15, 2016 at 12:25 PM, Eric Greer wrote: > > Thanks for the reply. What I'm trying to do is to make a web socket server > where all clients are sent broadcast messages. When the client connects, a > channel is creates and registered in a global list of client channels. When > a client d

Re: [go-nuts] Re: broadcasting on a set of channels

2016-06-15 Thread Eric Greer
Thanks for the reply. What I'm trying to do is to make a web socket server where all clients are sent broadcast messages. When the client connects, a channel is creates and registered in a global list of client channels. When a client disconnects, the channel gets closed. The broadcaster does not k

Re: [go-nuts] [ANN] Mirror of Go SSA

2016-06-15 Thread JW Bell
>>I have to say that I don't see a big benefit to mirroring a github repo on github itself. There isn't another way to use the ssa package. On Tuesday, June 14, 2016 at 10:15:19 PM UTC-7, Ian Lance Taylor wrote: > > On Tue, Jun 14, 2016 at 7:07 PM, > wrote: > > Mirror of the Go compiler SSA li

Re: [go-nuts] Re: Golang Grep

2016-06-15 Thread ToSuNuS
Hi Steven, I want to use a word that the data from this function. for example; f := func() { grep(flag.Arg(0), flag.Arg(1)) } if f == "domain.com" { } or handle := exec.Command("echo", string(f[1])).Output() Examples of these subject. My purpose is to convert the string. Regards. On Wedne

Re: [go-nuts] Re: Golang Grep

2016-06-15 Thread Steven Blenkinsop
Oh, sorry, didn't see that. `grep` doesn't return a value, so there's nothing to assign to a variable. What are you trying to do exactly? If you want a function value you can call repeatedly which will pass the same arguments to `grep`, you want: f := func() { grep(flag.Arg(1), flag.Arg(2)) }

[go-nuts] Re: Golang Grep

2016-06-15 Thread ToSuNuS
Hi, I forgot to mention. I'm new to this. Regards. On Wednesday, June 15, 2016 at 6:54:18 PM UTC+3, ToSuNuS wrote: > > Hi guys, > > How do I assign a variable function of sample scripts are used on the > following address? > > > https://github.com/StefanSchroeder/Golang-Regex-Tutorial/blob/mas

[go-nuts] Re: Golang Grep

2016-06-15 Thread ToSuNuS
Hi Steven, I mistyped the opening question. However, the script has been added correctly. Of course, the result is still the same. I run the command. go run test.go testword /root/testfile.txt Result: grep(flag.Arg(0), flag.Arg(1)) used as value I just add the following code. (to test)

Re: [go-nuts] Golang Grep

2016-06-15 Thread Steven Blenkinsop
Be careful with case. It should be flag.Arg(0), not flag.arg(0). Also, you're missing the comma between arguments. It should be: f := grep(flag.Arg(0), flag.Arg(1)) Note the comma between the two arguments. On Wed, Jun 15, 2016 at 11:54 AM ToSuNuS wrote: > Hi guys, > > How do I assign a variab

[go-nuts] Golang Grep

2016-06-15 Thread ToSuNuS
Hi guys, How do I assign a variable function of sample scripts are used on the following address? https://github.com/StefanSchroeder/Golang-Regex-Tutorial/blob/master/01-chapter3.markdown How can I define this as a variables of function . grep (flag.arg (0) flag.arg (1)) I tried as follows. H

Re: [go-nuts] Re: broadcasting on a set of channels

2016-06-15 Thread Ian Lance Taylor
On Tue, Jun 14, 2016 at 10:15 PM, wrote: > > What happens if the channel closes? > > I'm thinking about maintaining a list of channels (one for each websocket > client), then sending a message to all of them. The only problem is that > when the websocket client disconnects, their channel closes.

Re: [go-nuts] Bitmasks on signed types

2016-06-15 Thread 'Keith Randall' via golang-nuts
I do x & (0x - 1<<32). On Tuesday, June 14, 2016 at 1:44:14 PM UTC-7, Michael Jones wrote: > > I have fought this many times. > > What I almost always do is cast all variables involved as unsigned so that > I can express the logical operations as desired. The exception is right > shift

Re: [go-nuts] Hi! I'm happy to announce the very first release of *nexer* 1.0.0b simple and easy to use and extend content based network multiplexer

2016-06-15 Thread Diego Cena
Sure Konstantin! It means you can route network traffic based on transmitted content. A minimalistic example is the ur ltunnel type. :-) On Wednesday, June 15, 2016 at 7:58:36 AM UTC-3, Konstantin Khomoutov wrote: > > On Tue, 14 Jun 2016 17:29:33 -0700 (PDT) > Diego Cena > wrote: > > > *nex

[go-nuts] Re: broadcasting on a set of channels

2016-06-15 Thread integrii
Late reply, but still trying to figure something out here. What happens if the channel closes? I'm thinking about maintaining a list of channels (one for each websocket client), then sending a message to all of them. The only problem is that when the websocket client disconnects, their channel

[go-nuts] [ANN] GopherPit.com - service to manage remote import paths

2016-06-15 Thread Janoš Guljaš
Hello all, I would like to announce GopherPit [0], a web service to serve and manage go-import and go-source HTML meta tags. [1] That is the base functionality, but it supports custom domains, subdomains under gopherpit.com, automatic TLS certificate generation from Let’s Encrypt, team management

[go-nuts] Re: [ANN] primegen.go: Sieve of Atkin prime number generator

2016-06-15 Thread alb . donizetti
I suggest you to repeat your analysis on go1.7beta, the compiler has a new backend for amd64 and the generated code should be better. On my machine: go1.6.2: Found 2300 primes up to 262146 in 445.329735ms . Found 2300 primes up to 262146 in 447.491918ms . Found 2300 primes up to 2621

[go-nuts] Re: [ANN] primegen.go: Sieve of Atkin prime number generator

2016-06-15 Thread gordonbgood
While I am sure you are correct that some numeric code with golang can run as fast as C/C++, it seems that bit-packed tight loops such as used for culling composites in the Sieve of Eratosthenes (or the Sieve of Atkin for that matter) are not as optimized. Of course one of the problems that gol

Re: [go-nuts] Hi! I'm happy to announce the very first release of *nexer* 1.0.0b simple and easy to use and extend content based network multiplexer

2016-06-15 Thread Konstantin Khomoutov
On Tue, 14 Jun 2016 17:29:33 -0700 (PDT) Diego Cena wrote: > *nexer* is a simple and easy to use and extend content based network > multiplexer (or redirector) Could you please explain to the uninitiated in a couple of words what the heck "content-based network multiplexer" is? ;-) -- You rec