Re: [go-nuts] Re: RFC: Blog post: How to not use an HTTP router

2017-12-18 Thread 'Axel Wagner' via golang-nuts
On Tue, Dec 19, 2017 at 4:52 AM, 'Kean Ho Chew' via golang-nuts < golang-nuts@googlegroups.com> wrote: > >> I disagree. I am making the argument that the concept of a router is >> inherently broken. Writing your own router doesn't improve on that. Don't >> write a router, write routing logic. >>

[go-nuts] [ANN] You can now manipulate .ass/.ssa subtitles alongside .srt, .ttml, .vtt, .stl, etc. in GO

2017-12-18 Thread Asticode
Just to let you guys know I've added support for .ass/.ssa subtitles in go-astisub. You can still manipulate .srt, .ttml, .vtt, .stl, etc. and do parsing, writing, syncing, fragmenting, unfragmenting and merging. Support for Teletext coming soon.

[go-nuts] Why is the cpu usage so high in a golang tcp server?

2017-12-18 Thread Sokolov Yura
You didn't buffer writes. libevent does a good job at buffer managment. Go's net.Conn and os.File are unbuffered, ie they are almost "raw" file descriptors. You should use bufio.Writer and bufio.Reader, or make buffering by hands. (Just don't forget to flush bufio.Writer if response channel is

Re: [go-nuts] Is this a bug or am I missing something?

2017-12-18 Thread Jesse McNelis
On Tue, Dec 19, 2017 at 4:10 PM, Sasan Rose wrote: > Hi Jess > > Apologies for my bad example. Please kindly see my reply to Dave's post. > Thanks I fixed your example so that the slice called 'combination' isn't shared with every slice in every iteration of the loop.

Re: [go-nuts] Is this a bug or am I missing something?

2017-12-18 Thread Sasan Rose
Hi Jess Apologies for my bad example. Please kindly see my reply to Dave's post. Thanks On Tuesday, December 19, 2017 at 2:43:50 PM UTC+11, Jesse McNelis wrote: > > On Tue, Dec 19, 2017 at 8:54 AM, Sasan Rose > wrote: > > Please take a look at

[go-nuts] Re: Is this a bug or am I missing something?

2017-12-18 Thread Sasan Rose
Hi Dave, Apologies for the bad example. I tried to come up with a better and more meaningful example (Although maybe still not the best): https://play.golang.org/p/MornIhiiZ9 Imagine I want to find all the combinations of four different type of coins that have a sum value less than or equal

Re: [go-nuts] callback for c code wrapper around go function

2017-12-18 Thread Ian Lance Taylor
On Mon, Dec 18, 2017 at 5:31 AM, wrote: > > I want to write a c wrapper around a go code that has a callback > > func SomeGoComputation(address string, callback func(string,int)) { > _, err = // do some computation with address, maybe go over the > network >

Re: [go-nuts] Re: RFC: Blog post: How to not use an HTTP router

2017-12-18 Thread 'Kean Ho Chew' via golang-nuts
> > > I disagree. I am making the argument that the concept of a router is > inherently broken. Writing your own router doesn't improve on that. Don't > write a router, write routing logic. > > At some point you might have to agree with me. By abstracting the routing logic into a library to

Re: [go-nuts] Is this a bug or am I missing something?

2017-12-18 Thread Jesse McNelis
On Tue, Dec 19, 2017 at 8:54 AM, Sasan Rose wrote: > Please take a look at https://play.golang.org/p/BL4LUGk-lH solutionNew = make([]int, 0) solutionNew = append(solution, 2) Is a strange thing to do, you create a new slice using make([]int, 0) and then never use it.

[go-nuts] Re: Is this a bug or am I missing something?

2017-12-18 Thread Dave Cheney
Hi There, At this stage of development it's unlikely to be a bug in Go's slice implementation. I'd like to help but tbh your example is too long and I cannot follow what it does let alone what it should do. Could you please do two thing for me; 1. reduce the problem to the smallest possible

[go-nuts] SAST with Go Lang and Windows

2017-12-18 Thread 'Carlos Ortiz' via golang-nuts
Hey all, go this question from a customer. Can you all please advise? *We have a large team using the Go language for coding. We’ve found that CheckMarx has static application security testing (SAST) for Go and proposed using it, but the team pushed back saying they cannot support any

[go-nuts] SSH, HostKeyCallback and ssh.InsecureIgnoreHostKey

2017-12-18 Thread omerlin13
Hello, is it possible to get your full code example as I have exactly the same issue with Terraform and would like to prove it to Hashi Corp maintainer that pretends that this error could not happen because the Tcp session could not have been established... And so the host confirmation

[go-nuts] Is this a bug or am I missing something?

2017-12-18 Thread Sasan Rose
Please take a look at https://play.golang.org/p/BL4LUGk-lH I think I know how slices work (The 3-word structure). I tried to do my homework. But still I think I'm missing something here or it's really a bug. So In my code as you can see I'm appending to an slice (a variable called slice

[go-nuts] Re: Is flatbuffers useful for Golang?

2017-12-18 Thread Malcolm Gorman
FlatBuffers is a cross-platform binary format like protobuf and gob, but it is MUCH FASTER than protobuf and gob. It can be challenging to learn (at first) so I've written a library in Go which goes the extra mile and generates the FlatBuffers schema and Go code that glues the flatc code into a

[go-nuts] callback for c code wrapper around go function

2017-12-18 Thread roupesy
Hey guys, I want to write a c wrapper around a go code that has a callback func SomeGoComputation(address string, callback func(string,int)) { _, err = // do some computation with address, maybe go over the network if (err != nil) { callback(err.Error(), 0) }

Re: [go-nuts] Surprise About How Method Receivers Work

2017-12-18 Thread matthewjuran
Well you're talking about method receivers, not struct fields. It's a similar shortcut, but sorry about going off topic with the example. Matt On Monday, December 18, 2017 at 5:05:19 PM UTC-6, matthe...@gmail.com wrote: > > Here's a specific example of how this works for me. I have a chess

Re: [go-nuts] Surprise About How Method Receivers Work

2017-12-18 Thread matthewjuran
Here's a specific example of how this works for me. I have a chess board represented as a 64 element array of points: type Point struct { *Piece // nil for no piece AbsPoint } // Absolute Point represents a specific point on the board. type AbsPoint struct { File uint8 Rank uint8 } type

[go-nuts] [ANN] A blog post series on serving big satellite imagery with Go

2017-12-18 Thread Pablo Rozas Larraondo
Hi, For those interested on serving or using satellite imagery, I've just published the first of a three part series on this subject using Go: https://medium.com/@p.rozas.larraondo/divide-compress-and-conquer-building-an-earth-data-server-in-go-part-1-d82eee2eceb1 Any feedback or comment that

Re: [go-nuts] Surprise About How Method Receivers Work

2017-12-18 Thread jlforrest
On Monday, December 18, 2017 at 12:12:22 PM UTC-8, Dave Cheney wrote: > > It's true it is an exception, it's one of the few cases where the language > adds a pinch of syntactic sugar to make the experience more pleasurable. > I'd describe this more as removing a pinch of syntactic sugar. I

Re: [go-nuts] How to get nice html from godoc?

2017-12-18 Thread Justin Israel
On Tue, Dec 19, 2017, 9:28 AM Justin Israel wrote: > > > On Mon, Dec 18, 2017, 9:10 AM wrote: > >> Thanks Justin I will give it a try. >> >> (It certainly would be nice if "*godoc -html"* could be useful without >> having to modify the html.) >> > >

Re: [go-nuts] How to get nice html from godoc?

2017-12-18 Thread Justin Israel
On Mon, Dec 18, 2017, 9:10 AM wrote: > Thanks Justin I will give it a try. > > (It certainly would be nice if "*godoc -html"* could be useful without > having to modify the html.) > Seeing as how the godoc command serves the same style as godoc.org, it would be nice if it

Re: [go-nuts] Surprise About How Method Receivers Work

2017-12-18 Thread Dave Cheney
It's true it is an exception, it's one of the few cases where the language adds a pinch of syntactic sugar to make the experience more pleasurable. I can imagine without this the number one oft repeated feature request would be to _not_ have to write ().m() all the time when you just wanted to

[go-nuts] [ANN] dns - manipulate net.Dialer DNS queries

2017-12-18 Thread Ben Burkert
Hi Gophers, dns is a package for intercepting and modifying DNS queries generated by the stdlib's net package. Queries generated by a net.Dialer can be redirected to an alternative resolver, sent over a TLS connection, or answered and cached locally. It also includes a DNS server implementation.

[go-nuts] select multiple expressions per case

2017-12-18 Thread matthewjuran
I guess with select you can't do the comma for multiple cases having one behavior like with switch: select{ case <-c1, <-c2: // gofmt: expected 1 expression fmt.Println("c1 or c2") case <-c3: } switch s{ case v1, v2: fmt.Println("v1 or v2") case v3: } I assume this is because select

Re: [go-nuts] Surprise About How Method Receivers Work

2017-12-18 Thread Marvin Renich
* jlforr...@berkeley.edu [171217 15:33]: > Here's what I believe is the explanation. The book says (slightly > edited) "If the receiver p is a variable of type Path but the method > requires a *Path receiver, we can use this shorthand: > > p.pr1() > > and the compiler

[go-nuts] Re: Surprise About How Method Receivers Work

2017-12-18 Thread matthewjuran
With fmt you can print the pointer with %p. I like it better than the C way of . for value, and -> for the dereference shortcut instead of (*thing).field. Along with struct embedding I've had cases where C-like types act with object oriented level readability because of this Go feature. Matt

[go-nuts] Re: Is net.Conn concurrency-safe?

2017-12-18 Thread anmol via golang-nuts
Ah I see. You mean its obvious that multiple goroutines may invoke methods on a Conn simultaneously, your question is whether its safe or not, which the docs do not answer. The docs definitely intend on meaning that it is in fact safe to invoke methods on a Conn simultaneously. But I agree,

[go-nuts] Re: Is net.Conn concurrency-safe?

2017-12-18 Thread anmol via golang-nuts
Not sure where what is prompting your question, how are the docs misleading? The docs are very clear, net.Conn is concurrency safe. On Monday, December 18, 2017 at 7:51:26 AM UTC-5, SP wrote: > > In the documentation for https://golang.org/pkg/net/#Conn, it's stated > that > > Multiple

Re: [go-nuts] Re: RFC: Blog post: How to not use an HTTP router

2017-12-18 Thread 'Axel Wagner' via golang-nuts
On Mon, Dec 18, 2017 at 5:50 AM, 'Kean Ho Chew' via golang-nuts < golang-nuts@googlegroups.com> wrote: > IMO, this article itself is indeed indicating there is an important > feature not fulfilled by the standard package. It is asking people to write > their own routers indirectly > I disagree.

[go-nuts] Re: Why is the cpu usage so high in a golang tcp server?

2017-12-18 Thread Tamás Gulácsi
2017. december 18., hétfő 14:11:34 UTC+1 időpontban Tamás Gulácsi a következőt írta: > > > 2017. december 18., hétfő 13:51:26 UTC+1 időpontban eric.sh...@gmail.com > a következőt írta: >> >> I try to implement a golang tcp server, and I found the concurrency is >> satisfied for me, but the

[go-nuts] Re: Why is the cpu usage so high in a golang tcp server?

2017-12-18 Thread Tamás Gulácsi
2017. december 18., hétfő 13:51:26 UTC+1 időpontban eric.sh...@gmail.com a következőt írta: > > I try to implement a golang tcp server, and I found the concurrency is > satisfied for me, but the CPU usage is too high(concurrency is 15W+/s, but > the CPU usage is about 800% in a 24 cores linux

[go-nuts] Re: Sending C array over gob ; decoding shows wrong data

2017-12-18 Thread Tamás Gulácsi
Use a Go struct for GOB encoding/decoding. 2017. december 18., hétfő 13:51:26 UTC+1 időpontban Kanika Kakkar a következőt írta: > > I am sending a C structure which looks like this > > typdef struct > { > unsigned char field1; > unsigned char field2; > unsigned char array[10]; >

[go-nuts] Re: RFC: Blog post: How to not use an HTTP router

2017-12-18 Thread 'Kean Ho Chew' via golang-nuts
IMO, this article itself is indeed indicating there is an important feature not fulfilled by the standard package. It is asking people to write their own routers indirectly, thus, leading to the current situation (e.g: more routers). There is a much better guide here:

[go-nuts] Why is the cpu usage so high in a golang tcp server?

2017-12-18 Thread eric . shen881027
I try to implement a golang tcp server, and I found the concurrency is satisfied for me, but the CPU usage is too high(concurrency is 15W+/s, but the CPU usage is about 800% in a 24 cores linux machine). At the same time, a C++ tcp server is only about 200% usage with a similar

[go-nuts] Is net.Conn concurrency-safe?

2017-12-18 Thread sanjay . paul
In the documentation for https://golang.org/pkg/net/#Conn, it's stated that Multiple goroutines may invoke methods on a Conn simultaneously. My guess is this is not meant to imply that it is necessarily safe to do so. For instance, calls to Set*Deadline may create race conditions between

[go-nuts] Sending C array over gob ; decoding shows wrong data

2017-12-18 Thread kanikakakkar711
I am sending a C structure which looks like this typdef struct { unsigned char field1; unsigned char field2; unsigned char array[10]; }complete_data_t; I am encoding this data using GOB and sending as UDP broadcast in a very small network. On the receiver side, all fields are correctly