[go-nuts] Marshal XML Mixed Content

2016-10-10 Thread Scott
I'm trying to Marshal XML where an element has mixed content: 
https://www.w3.org/TR/REC-xml/#sec-mixed-content

I tried just using []interface{} but if I put in just a string, Marshal 
surrounds each string with the name of the slice:

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

I'm trying to get the output to be:
  
  foo
  hello
  bar
  world
  

Any ideas?
Thanks,
Scott

-- 
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: time representation to use with javascript

2016-10-10 Thread bsr
Just saw that time implements MarshalJSON, so may be string output may be 
better.
https://golang.org/src/time/time.go?s=26891:26934#L918

On Monday, October 10, 2016 at 11:22:48 PM UTC-4, bsr wrote:
>
> Hello,
>
> I store all time values in UTC, and since it runs on google app engine, 
> the precision might be in microseconds.
> https://github.com/golang/appengine/blob/master/datastore/save.go#L21
>
> I want to display this time in client side with moment.js. But, javascript 
> doesn't support int64, so how should I send the time value (which is an 
> int64 at microseconds precision) to client. moment only supports time at 
> milliseconds 
> precision 
> . But, I 
> am not sure what is the best way to convert int64 to javascript number 
> (it is ok to lose 
> precision to milliseconds).
>
> Thank you,
> 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.


[go-nuts] time representation to use with javascript

2016-10-10 Thread bsr
Hello,

I store all time values in UTC, and since it runs on google app engine, the 
precision might be in microseconds.
https://github.com/golang/appengine/blob/master/datastore/save.go#L21

I want to display this time in client side with moment.js. But, javascript 
doesn't support int64, so how should I send the time value (which is an 
int64 at microseconds precision) to client. moment only supports time at 
milliseconds 
precision . 
But, I am not sure what is the best way to convert int64 to javascript 
number (it is ok to lose 
precision to milliseconds).

Thank you,
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.


[go-nuts] SQLBoiler Screencast - Getting Started

2016-10-10 Thread Patrick O'Brien
We've made a screen cast highlighting how to get started using the 
SQLBoiler ORM generator. Please let us know what you think: 

https://www.youtube.com/watch?v=fKmRemtmi0Y

-- 
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 Review for TLS Proxies

2016-10-10 Thread 'Anmol Sethi' via golang-nuts
My school uses DPI (deep packet inspection) to block protocols like SSH and
OpenVPN. Additionally, few remote ports are enabled. Sometimes I want to
login to my VPS from school to fix or work on something, but I cannot
because SSH is blocked. Furthermore, my school has a approved (yes,
approved by the school administration) League Of Legends team but they
cannot play League Of Legends at school because it is blocked...

In order to get around these limitations, I've written tlswrapd
 and tlsmuxd
.

tlswrapd accepts a local connection, dials a remote address with TLS and
then copies all data between the two connections. tlsmuxd accepts a remote
connection with TLS, dials a local address and then copies all data between
the two connections. Both also support ALPN to serve multiple protocols
over a single port.

Since TLS and port 443 are not blocked, this allows me to serve protocols
like SSH and OpenVPN over TLS on port 443 on my VPS. I use tlswrapd on my
laptop to "wrap" SSH connections to my VPS where tlsmuxd is running.
tlsmuxd then proxies these SSH connections back to the locally running
sshd. It does essentially the same thing for OpenVPN.

I've put in a lot of effort to make the code idiomatic and secure but I
would appreciate some feedback.

Thanks in advance!

-- 
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] Gleam - A Go-based MapReduce system with Luajit, Unix Pipes

2016-10-10 Thread Chris Lu
Thanks for the question! It's nice that you know glow.

Gleam is very similar to glow, but has a very different approach after some
rethinking.

Glow is based on channels and reflection, which are less performant. There
is a performance comparison example:
https://github.com/chrislusf/gleam/blob/master/examples/pi_estimation/pi_estimation.go

Glow is based on pure go, which is not flexible to dynamically change
execution path. It's hard to build more advanced generic use cases. With
Gleam, we can build a distributed SQL execution engine, for example.

Gleam uses Luajit. Lua is small and simple. Luajit has performance
comparable to C, Java, and Go, and it comes automatically with
"generics". It is a nice compliment to Go for distributed computing.

Chris

On Mon, Oct 10, 2016 at 4:53 PM, Mandolyte  wrote:

> How is this connected with your glow package? Layered on top of?
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/golang-nuts/CuxsXzyd4Eg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [go-nuts] Re: what's the difference between Golang and Java about interface?

2016-10-10 Thread Henrik Johansson
Yet a notable such marker interface Serializable is known by almost all
Java developers ;)

On Tue, Oct 11, 2016, 02:04  wrote:

> An interesting aside about Java Interfaces that most people don't know is
> that you can have an empty Interface without methods or members and then
> declare different objects as implementing that empty interface. The purpose
> of this in Java is different then in Golang but it allows arbitrary
> instance of classes (objects) to be passed around without using Object as
> the class. I found this out while looking at Koopla source code and it is a
> handy trick for Java programmers to know. Sorry, this hint isn't really
> about Golang.
>
>
> On Saturday, October 8, 2016 at 9:14:34 AM UTC-4, Fei Ding wrote:
>
> Recently I've been asked a question which is, what's the difference
> between Golang and Java about *interface*?
>
>
> I know there are some 'syntax-sugar level' differences, what I am
> interested is anything beneath the ground, like how does Golang and Java
> implement interface? What's the biggest difference? Which one is more
> efficient? Why?
>
>
> Could anyone post blog links or source code about this topic? The only
> code I can find is in src/runtime/iface.go, but I cannot understand it or
> get anything useful by myself yet. Source code is better.
>
>
> 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.
>

-- 
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: what's the difference between Golang and Java about interface?

2016-10-10 Thread gottadoit
An interesting aside about Java Interfaces that most people don't know is 
that you can have an empty Interface without methods or members and then 
declare different objects as implementing that empty interface. The purpose 
of this in Java is different then in Golang but it allows arbitrary 
instance of classes (objects) to be passed around without using Object as 
the class. I found this out while looking at Koopla source code and it is a 
handy trick for Java programmers to know. Sorry, this hint isn't really 
about Golang.

On Saturday, October 8, 2016 at 9:14:34 AM UTC-4, Fei Ding wrote:
>
> Recently I've been asked a question which is, what's the difference 
> between Golang and Java about *interface*?
>
>
> I know there are some 'syntax-sugar level' differences, what I am 
> interested is anything beneath the ground, like how does Golang and Java 
> implement interface? What's the biggest difference? Which one is more 
> efficient? Why?
>
>
> Could anyone post blog links or source code about this topic? The only 
> code I can find is in src/runtime/iface.go, but I cannot understand it or 
> get anything useful by myself yet. Source code is better.
>
>
> 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: [ANN] gorram: like go run for any* function in stdlib or GOPATH

2016-10-10 Thread Mathieu Lonjaret
Looks shiny!
But is there some sort of cache I have to clear? I've just updated and
rebuilt, and I still get the old behaviour.


On 8 October 2016 at 04:05, Nate Finch  wrote:
> ...and now it works like you'd hope :)
>
>
> $ gorram net/http Get https://npf.io/gorram/run
>  href="https://npf.io/gorram/"/> content="text/html; charset=utf-8" /> content="0;url=https://npf.io/gorram/; />
>
> or if you want to get fancy:
>
> $ gorram net/http Get https://npf.io/gorram/run | gorram
> github.com/yosssi/gohtml Format
> 
> 
>   
> https://npf.io/gorram/"/>
> 
> https://npf.io/gorram/; />
>   
> 
>
> --
> 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] what's the difference between Golang and Java about interface?

2016-10-10 Thread Haddock


Am Samstag, 8. Oktober 2016 17:31:27 UTC+2 schrieb Pietro Gagliardi 
(andlabs):
>
> In Java, if an interface contains exactly one method, and that method is 
> not already part of java.lang.Object, the syntax
>
> Interface i = (arguments) -> {
> code
> };
>
> will make an object i of that interface type with the given closure as the 
> method body. This interface is called a functional interface.
>
> Pre-Java 8, the same thing could be done with
>
> Interface i = new Interface() {
> public void method() {
> code
> }
> };
>
>
The number of methods in a Java interface is of course arbitrary and not 
restricted to a single one. The first code sample above shows a Java8 lamda 
expression which inevitably consists of the lambda function itself. Lambdas 
in Java8 implement a variety of interfaces, but this does not mean that 
interfaces in Java must only contain one method.

The biggest difference is that a "class" or struct in Go implicitly 
implements an interface once it contains all the methods defined in some Go 
interface. In Java a a class must explicitly implement an interface.

As what lambdas or closures are concerned Go supports full-fledges 
closures, which means support for non-local returns, variables outside the 
closure are writeable. This is not the case in Java and in Java you cannot 
throw checked exceptions from within a closure. These limitations in Java 
are all due to (binary) backwards compatibility and limitations of the JVM 
(e.g. non-local returns).

-- 
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] lxn/walk goroutine blocks

2016-10-10 Thread rbirac
Hi Guys,
I’m building a GUI for my robot.  I’m using Windows, so found lxn/walk.   
Working from the examples, I built a GUI which did all that I want right 
now.  I developed it in the main() function, just like the examples; but 
for the actual robot, I want it to run in its own goroutine with the code 
in a separate package.  Well, I can’t make that work.  I can’t even get it 
to work as a goroutine in main().
The minimal example code below demonstrates the problem.  The main() 
function has two ways to start the GUI.  If I run the “Gui()” version.  The 
GUI appears on the screen as expected and the controls function.  However, 
the subsequent 5 second Sleep and Println() don’t begin to run until I 
close the GUI window by clicking the X.  If I run the “go Gui()” version, 
 The GUI does not appear on the screen, but the code does continue and 
prints after the 5 second sleep.
I expect that it is possible to do what I want (i.e.  "go Gui” with 
continuation to the sleep and Println).  I am pretty much a newbie, but I 
have written a number of relatively complex goroutines that don’t have this 
problem.
I’m running on Windows 10 (x64) with go 1.6.2 on LiteIDE X29 and a very 
recent walk download.
I’m hoping someone can point out my possible naïve error, or maybe a link 
to some code that does what I want.
Thanks,
Alex

package main


import (

"fmt"

"time"

. "github.com/lxn/walk/declarative"

)


func main() {

//Gui() //  draws operative GUI window, but blocks from continuing to Sleep 
and Println

go Gui() // doesn't draw GUI window. Continues and does Println after 5 
seconds


time.Sleep(time.Millisecond * 5000)

fmt.Println("testing")

}


func Gui() {

MainWindow{

Title:   "SCREAMO",

MinSize: Size{600, 400},

}.Run()

}


-- 
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] go install with -installsuffix fails on linux but not mac?

2016-10-10 Thread Ian Rose
(sorry if I already sent this - groups UI being weird)

Hmm... I seem to get the same results on both machines:

Mac:

$ go list -f '{{.Name}} {{.Stale}}' std  | grep true | head
$ go list -installsuffix nocgo -f '{{.Name}} {{.Stale}}' std  | grep true | 
head
tar true
zip true
bzip2 true
lzw true
zlib true
ring true
tls true
x509 true
sql true
driver true


Linux:

ianrose@iantest-1:~$ go list -f '{{.Name}} {{.Stale}}' std  | grep true | 
head
ianrose@iantest-1:~$ go list -installsuffix nocgo -f '{{.Name}} {{.Stale}}' 
std  | grep true | head
tar true
zip true
bufio true
bytes true
bzip2 true
flate true
gzip true
lzw true
zlib true
heap true


It's like the mac version somehow knows not to try to save pkg files for 
std libs...


On Monday, October 10, 2016 at 4:16:32 PM UTC-4, Ian Lance Taylor wrote:
>
> On Mon, Oct 10, 2016 at 12:48 PM, Ian Rose  > wrote: 
> > On my macbook pro, I'm able to `go install` with a custom installsuffix 
> just 
> > fine: 
> > 
> > 
> > $ ls -l /usr/local/go/pkg/ 
> > total 0 
> > drwxr-xr-x   5 root  wheel   170 Feb 25  2016 bootstrap 
> > drwxr-xr-x  58 root  wheel  1972 Feb 25  2016 darwin_amd64 
> > drwxr-xr-x  57 root  wheel  1938 Sep  8  2015 darwin_amd64_race 
> > drwxr-xr-x   4 root  wheel   136 Sep  8  2015 include 
> > drwxr-xr-x   3 root  wheel   102 Feb 25  2016 obj 
> > drwxr-xr-x   3 root  wheel   102 Feb 25  2016 tool 
> > 
> > 
> > $ go install -installsuffix nocgo golang.org/x/tools/cmd/goimports 
> > $ echo $? 
> > 0 
> > $ echo $GOROOT 
> > 
> > 
> > $ ls -l /usr/local/go/pkg/ 
> > total 0 
> > drwxr-xr-x   5 root  wheel   170 Feb 25  2016 bootstrap 
> > drwxr-xr-x  58 root  wheel  1972 Feb 25  2016 darwin_amd64 
> > drwxr-xr-x  57 root  wheel  1938 Sep  8  2015 darwin_amd64_race 
> > drwxr-xr-x   4 root  wheel   136 Sep  8  2015 include 
> > drwxr-xr-x   3 root  wheel   102 Feb 25  2016 obj 
> > drwxr-xr-x   3 root  wheel   102 Feb 25  2016 tool 
> > 
> > 
> > But on a linux machine, it fails: 
> > 
> > $ ls -l /usr/local/go/pkg/ 
> > total 20 
> > drwxr-xr-x  2 root root 4096 Jan 13  2016 include 
> > drwxr-xr-x 29 root root 4096 Jan 13  2016 linux_amd64 
> > drwxr-xr-x 28 root root 4096 Jan 13  2016 linux_amd64_race 
> > drwxr-xr-x  3 root root 4096 Jan 13  2016 obj 
> > drwxr-xr-x  3 root root 4096 Jan 13  2016 tool 
> > 
> > 
> > $ GOPATH=`pwd`/go go install -installsuffix nocgo 
> > golang.org/x/tools/cmd/goimports 
> > go install runtime: mkdir /usr/local/go/pkg/linux_amd64_nocgo/: 
> permission 
> > denied 
> > 
> > 
> > The obvious difference appears to be that on my Mac, the go tool isn't 
> > trying to write out .a files for the core lib packages that are compiled 
> > with the new installsuffix, whereas on Linux it is trying to do so. 
>
> I doubt this has anything to do with Mac vs. GNU/Linux.  I suspect 
> there is something about the way that Go is installed on your 
> GNU/Linux system that makes the standard packages appear out of date. 
> By default the go tool will not attempt to reinstall the standard 
> packages, even if they appear out of date.  But when you specify 
> -installsuffix, the algorithm changes, and now it matters whether the 
> package is out of date or not. 
>
> To see the list of out-of-date packages, try running 
> go list -f '{{.Name}} {{.Stale}}' std 
> It will print `true` for each package it thinks is out of date. 
>
> 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] go install with -installsuffix fails on linux but not mac?

2016-10-10 Thread Ian Lance Taylor
On Mon, Oct 10, 2016 at 12:48 PM, Ian Rose  wrote:
> On my macbook pro, I'm able to `go install` with a custom installsuffix just
> fine:
>
>
> $ ls -l /usr/local/go/pkg/
> total 0
> drwxr-xr-x   5 root  wheel   170 Feb 25  2016 bootstrap
> drwxr-xr-x  58 root  wheel  1972 Feb 25  2016 darwin_amd64
> drwxr-xr-x  57 root  wheel  1938 Sep  8  2015 darwin_amd64_race
> drwxr-xr-x   4 root  wheel   136 Sep  8  2015 include
> drwxr-xr-x   3 root  wheel   102 Feb 25  2016 obj
> drwxr-xr-x   3 root  wheel   102 Feb 25  2016 tool
>
>
> $ go install -installsuffix nocgo golang.org/x/tools/cmd/goimports
> $ echo $?
> 0
> $ echo $GOROOT
>
>
> $ ls -l /usr/local/go/pkg/
> total 0
> drwxr-xr-x   5 root  wheel   170 Feb 25  2016 bootstrap
> drwxr-xr-x  58 root  wheel  1972 Feb 25  2016 darwin_amd64
> drwxr-xr-x  57 root  wheel  1938 Sep  8  2015 darwin_amd64_race
> drwxr-xr-x   4 root  wheel   136 Sep  8  2015 include
> drwxr-xr-x   3 root  wheel   102 Feb 25  2016 obj
> drwxr-xr-x   3 root  wheel   102 Feb 25  2016 tool
>
>
> But on a linux machine, it fails:
>
> $ ls -l /usr/local/go/pkg/
> total 20
> drwxr-xr-x  2 root root 4096 Jan 13  2016 include
> drwxr-xr-x 29 root root 4096 Jan 13  2016 linux_amd64
> drwxr-xr-x 28 root root 4096 Jan 13  2016 linux_amd64_race
> drwxr-xr-x  3 root root 4096 Jan 13  2016 obj
> drwxr-xr-x  3 root root 4096 Jan 13  2016 tool
>
>
> $ GOPATH=`pwd`/go go install -installsuffix nocgo
> golang.org/x/tools/cmd/goimports
> go install runtime: mkdir /usr/local/go/pkg/linux_amd64_nocgo/: permission
> denied
>
>
> The obvious difference appears to be that on my Mac, the go tool isn't
> trying to write out .a files for the core lib packages that are compiled
> with the new installsuffix, whereas on Linux it is trying to do so.

I doubt this has anything to do with Mac vs. GNU/Linux.  I suspect
there is something about the way that Go is installed on your
GNU/Linux system that makes the standard packages appear out of date.
By default the go tool will not attempt to reinstall the standard
packages, even if they appear out of date.  But when you specify
-installsuffix, the algorithm changes, and now it matters whether the
package is out of date or not.

To see the list of out-of-date packages, try running
go list -f '{{.Name}} {{.Stale}}' std
It will print `true` for each package it thinks is out of date.

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] go install with -installsuffix fails on linux but not mac?

2016-10-10 Thread Ian Rose
On my macbook pro, I'm able to `go install` with a custom installsuffix 
just fine:


$ ls -l /usr/local/go/pkg/
total 0
drwxr-xr-x   5 root  wheel   170 Feb 25  2016 bootstrap
drwxr-xr-x  58 root  wheel  1972 Feb 25  2016 darwin_amd64
drwxr-xr-x  57 root  wheel  1938 Sep  8  2015 darwin_amd64_race
drwxr-xr-x   4 root  wheel   136 Sep  8  2015 include
drwxr-xr-x   3 root  wheel   102 Feb 25  2016 obj
drwxr-xr-x   3 root  wheel   102 Feb 25  2016 tool


$ go install -installsuffix nocgo golang.org/x/tools/cmd/goimports
$ echo $?
0
$ echo $GOROOT


$ ls -l /usr/local/go/pkg/
total 0
drwxr-xr-x   5 root  wheel   170 Feb 25  2016 bootstrap
drwxr-xr-x  58 root  wheel  1972 Feb 25  2016 darwin_amd64
drwxr-xr-x  57 root  wheel  1938 Sep  8  2015 darwin_amd64_race
drwxr-xr-x   4 root  wheel   136 Sep  8  2015 include
drwxr-xr-x   3 root  wheel   102 Feb 25  2016 obj
drwxr-xr-x   3 root  wheel   102 Feb 25  2016 tool


But on a linux machine, it fails:

$ ls -l /usr/local/go/pkg/
total 20
drwxr-xr-x  2 root root 4096 Jan 13  2016 include
drwxr-xr-x 29 root root 4096 Jan 13  2016 linux_amd64
drwxr-xr-x 28 root root 4096 Jan 13  2016 linux_amd64_race
drwxr-xr-x  3 root root 4096 Jan 13  2016 obj
drwxr-xr-x  3 root root 4096 Jan 13  2016 tool


$ GOPATH=`pwd`/go go install -installsuffix nocgo golang.org/x/tools/cmd/
goimports
go install runtime: mkdir /usr/local/go/pkg/linux_amd64_nocgo/: permission 
denied


The obvious difference appears to be that on my Mac, the go tool isn't 
trying to write out .a files for the core lib packages that are compiled 
with the new installsuffix, whereas on Linux it *is* trying to do so.

Why is this?  What is the recommended way to use a custom installsuffix on 
linux (efficiently - i.e. without recompiling all dependencies every time)?

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.


Re: [go-nuts] big.Rat anomalies

2016-10-10 Thread Michael Jones
Dave, try this version: https://play.golang.org/p/p5zyQF1Sdr

 

From:  on behalf of Jan Mercl <0xj...@gmail.com>
Date: Monday, October 10, 2016 at 4:40 PM
To: Dave Cohen , golang-nuts 

Subject: Re: [go-nuts] big.Rat anomalies

 


On Mon, Oct 10, 2016 at 4:29 PM Dave Cohen  wrote:

> numerator.SetFloat64(118.5285714285714) // becomes 
> 118.528571428571396495499357115477
> big.NewRat(592642857142857, 5) // becomes 
> 118.52857142857140 - more accurate than SetFloat64 above!
>
> So my first question is why is SetFloat64() less accurate than the ratio used 
> in NewRat() above?

 

A float64 number has only 53 bits of mantissa precision while the result of 
big.NewRat is always exact (has infinite precision).

 

-- 

-j

-- 
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] spec:

2016-10-10 Thread T L
Thanks for the explanation.

On Tuesday, October 11, 2016 at 12:55:06 AM UTC+8, Ian Lance Taylor wrote:
>
> On Mon, Oct 10, 2016 at 9:51 AM, T L  
> wrote: 
> > 
> > On Tuesday, October 11, 2016 at 12:19:10 AM UTC+8, Ian Lance Taylor 
> wrote: 
> >> 
> >> On Mon, Oct 10, 2016 at 8:39 AM, T L  wrote: 
> >> > In the section of go spec: 
> >> > https://golang.org/ref/spec#Uniqueness_of_identifiers, it says: 
> >> > 
> >> > Two identifiers are different if they are spelled differently, or if 
> >> > they 
> >> > appear in different packages and are not exported. Otherwise, they 
> are 
> >> > the 
> >> > same. 
> >> > 
> >> > So, two exported identifiers spelled same but in different packages 
> are 
> >> > the 
> >> > same identifiers? 
> >> > Is my understanding right? 
> >> 
> >> Yes.  But don't confuse the fact that the identifiers are the same 
> >> with whether the objects that the identifiers denote are the same. 
> >> 
> >> The different handling of exported and unexported identifiers 
> >> particularly comes up with identifiers that denote struct fields or 
> >> methods, particularly when deciding how to handle embedded types and 
> >> promoted fields or methods. 
> >> 
> >> Ian 
> > 
> > 
> > So it is meaningless to prove two package-level identifiers, in two 
> > different packages, are the same? 
>
> If you strictly mean package level, as in a const, func, type, or var 
> defined in the package block, then, yes, I think it is meaningless. 
>
> 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] spec:

2016-10-10 Thread Ian Lance Taylor
On Mon, Oct 10, 2016 at 9:51 AM, T L  wrote:
>
> On Tuesday, October 11, 2016 at 12:19:10 AM UTC+8, Ian Lance Taylor wrote:
>>
>> On Mon, Oct 10, 2016 at 8:39 AM, T L  wrote:
>> > In the section of go spec:
>> > https://golang.org/ref/spec#Uniqueness_of_identifiers, it says:
>> >
>> > Two identifiers are different if they are spelled differently, or if
>> > they
>> > appear in different packages and are not exported. Otherwise, they are
>> > the
>> > same.
>> >
>> > So, two exported identifiers spelled same but in different packages are
>> > the
>> > same identifiers?
>> > Is my understanding right?
>>
>> Yes.  But don't confuse the fact that the identifiers are the same
>> with whether the objects that the identifiers denote are the same.
>>
>> The different handling of exported and unexported identifiers
>> particularly comes up with identifiers that denote struct fields or
>> methods, particularly when deciding how to handle embedded types and
>> promoted fields or methods.
>>
>> Ian
>
>
> So it is meaningless to prove two package-level identifiers, in two
> different packages, are the same?

If you strictly mean package level, as in a const, func, type, or var
defined in the package block, then, yes, I think it is meaningless.

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] spec:

2016-10-10 Thread T L


On Tuesday, October 11, 2016 at 12:19:10 AM UTC+8, Ian Lance Taylor wrote:
>
> On Mon, Oct 10, 2016 at 8:39 AM, T L  
> wrote: 
> > In the section of go spec: 
> > https://golang.org/ref/spec#Uniqueness_of_identifiers, it says: 
> > 
> > Two identifiers are different if they are spelled differently, or if 
> they 
> > appear in different packages and are not exported. Otherwise, they are 
> the 
> > same. 
> > 
> > So, two exported identifiers spelled same but in different packages are 
> the 
> > same identifiers? 
> > Is my understanding right? 
>
> Yes.  But don't confuse the fact that the identifiers are the same 
> with whether the objects that the identifiers denote are the same. 
>
> The different handling of exported and unexported identifiers 
> particularly comes up with identifiers that denote struct fields or 
> methods, particularly when deciding how to handle embedded types and 
> promoted fields or methods. 
>
> Ian 
>

So it is meaningless to prove two package-level identifiers, in two 
different packages, are the same?

-- 
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] spec:

2016-10-10 Thread Jan Mercl
On Mon, Oct 10, 2016 at 6:29 PM T L  wrote:

> So, two non-exported identifiers spelled same but in different packages
are the same identifiers?

See Ian's answer. Note also the specs's preceding sentence: "Given a set of
identifiers."

-- 

-j

-- 
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] vim setup for auto go fmt on save.

2016-10-10 Thread Tarsis Azevedo
Fatih, vim-go author, wrote awesome tutorial about that.
https://github.com/fatih/vim-go-tutorial/blob/master/README.md

Tarsis Figueredo Azevedo.
---
Celular: (21) 998524668
@tarsisazevedo 
---


On Mon, Oct 10, 2016 at 10:24 AM, Grzegorz Żur 
wrote:

> This will run go fmt on save.
>
> :autocmd BufWritePost *.go silent ! go fmt >/dev/null
>
> On Monday, 10 October 2016 14:04:21 UTC+2, 김용빈 wrote:
>>
>> Tank you Sander.
>>
>> I successfully installed and it works well.
>>
>> Still I want to know simple way though.
>> If anyone knows about it, please let me know. :)
>>
>> --
> 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] spec:

2016-10-10 Thread T L


On Tuesday, October 11, 2016 at 12:21:01 AM UTC+8, Jan Mercl wrote:
>
> On Mon, Oct 10, 2016 at 6:01 PM Paul Borman  > wrote:
>
> > In your representation, P means "identifiers are different", so the 
> resulting false means the identifiers are the same, which is what the OP 
> asked.
>
> I put it simple but I still managed to misread my own simple code 
> correctly because the assumption of the result. Wonderful.
>
> -- 
>
> -j
>

So, two non-exported identifiers spelled same but in different packages are 
the same identifiers?  

-- 
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] spec:

2016-10-10 Thread Jan Mercl
On Mon, Oct 10, 2016 at 6:01 PM Paul Borman  wrote:

> In your representation, P means "identifiers are different", so the
resulting false means the identifiers are the same, which is what the OP
asked.

I put it simple but I still managed to misread my own simple code correctly
because the assumption of the result. Wonderful.

-- 

-j

-- 
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] spec:

2016-10-10 Thread Ian Lance Taylor
On Mon, Oct 10, 2016 at 8:39 AM, T L  wrote:
> In the section of go spec:
> https://golang.org/ref/spec#Uniqueness_of_identifiers, it says:
>
> Two identifiers are different if they are spelled differently, or if they
> appear in different packages and are not exported. Otherwise, they are the
> same.
>
> So, two exported identifiers spelled same but in different packages are the
> same identifiers?
> Is my understanding right?

Yes.  But don't confuse the fact that the identifiers are the same
with whether the objects that the identifiers denote are the same.

The different handling of exported and unexported identifiers
particularly comes up with identifiers that denote struct fields or
methods, particularly when deciding how to handle embedded types and
promoted fields or methods.

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] spec:

2016-10-10 Thread 'Paul Borman' via golang-nuts
In your representation, P means "identifiers are different", so the
resulting false means the identifiers are the same, which is what the OP
asked.

On Mon, Oct 10, 2016 at 8:47 AM, Jan Mercl <0xj...@gmail.com> wrote:

>
> On Mon, Oct 10, 2016 at 5:39 PM T L  wrote:
>
> > Two identifiers are different if they are spelled differently, or if
> they appear in different packages 
> and are not exported .
> Otherwise, they are the same.
> >
> > So, two exported identifiers spelled same but in different packages are
> the same identifiers?
> > Is my understanding right?
>
> No.
>
> P =  spelledDifferently || appearInDifferentPackages && !exported
>
> For "two exported identifiers spelled same but in different packages" we
> have
>
> P = false || true && false.
>
> --
>
> -j
>
> --
> 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] Turning off nagle's algorithm for http.Client

2016-10-10 Thread hay
I stand corrected, it is there in "newTCPConn" function.

On Monday, October 10, 2016 at 10:16:27 AM UTC+4, Sokolov Yura wrote:
>
> Read carefully, and you will not need to do redundant work and write 
> redundant code.
>
> It is really here: 
> https://github.com/golang/go/blob/release-branch.go1.6/src/net/tcpsock_posix.go
>
> If you don't see it... Then you reading skill is weak.
>
>

-- 
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] spec:

2016-10-10 Thread Jan Mercl
On Mon, Oct 10, 2016 at 5:39 PM T L  wrote:

> Two identifiers are different if they are spelled differently, or if they
appear in different packages  and are
not exported . Otherwise,
they are the same.
>
> So, two exported identifiers spelled same but in different packages are
the same identifiers?
> Is my understanding right?

No.

P =  spelledDifferently || appearInDifferentPackages && !exported

For "two exported identifiers spelled same but in different packages" we
have

P = false || true && false.

-- 

-j

-- 
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] spec:

2016-10-10 Thread T L
In the section of go spec: 
https://golang.org/ref/spec#Uniqueness_of_identifiers, it says:

Two identifiers are different if they are spelled differently, or if they 
appear in different packages  and are 
not exported . Otherwise, 
they are the same.

So, two exported identifiers spelled same but in different packages are the 
same identifiers? 
Is my understanding right?

-- 
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] big.Rat anomalies

2016-10-10 Thread Jan Mercl
On Mon, Oct 10, 2016 at 4:29 PM Dave Cohen  wrote:

> numerator.SetFloat64(118.5285714285714) // becomes
118.528571428571396495499357115477
> big.NewRat(592642857142857, 5) // becomes
118.52857142857140 - more accurate than SetFloat64 above!
>
> So my first question is why is SetFloat64() less accurate than the ratio
used in NewRat() above?

A float64 number has only 53 bits of mantissa precision while the result of
big.NewRat is always exact (has infinite precision).

-- 

-j

-- 
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] big.Rat anomalies

2016-10-10 Thread Dave Cohen
I'm getting an unexpected result of big.Rat.Quo().  In trying to track it 
down, I ran into an unexpected result from big.Rat.SetFloat64().  So I have 
a few questions...

Code snippet below reproduces what I see in my application, and is also in 
https://play.golang.org/p/Eph67_1yd-

I'm working with data that includes pairs of decimal numbers, and I need 
the ratio between each pair.  Originally, I started implementing with 
float64s.  But I ran into some rounding errors and something I read 
somewhere (maybe this list) led me to think that big.Rat would be a better 
choice.  Using bigRat solved my problem at the time, but now in processing 
a particular list of numbers I'm noticing an error.

The result I would like is for input two values, 118.5285714285714 
and 8297.0, is an output ratio should be 0.01428571428571428.  I get this 
on a calculator, but not code using bit.Rat.

Using big.Rat, getting the 8297 denominator is straightforward.

Getting the numerator is tricky.  Note these two approaches get different 
results:

numerator.SetFloat64(118.5285714285714) // becomes 
118.528571428571396495499357115477
big.NewRat(592642857142857, 5) // becomes 
118.52857142857140 - more accurate than SetFloat64 above!


So my first question is why is SetFloat64() less accurate than the ratio 
used in NewRat() above?

Next question is why do neither of these numerators get the expected result 
from big.Rat.Quo()?  See output of code below (shown in comments).

And given these problems, should I be using some other package to perform 
this math?  Or, am I making some mistake in how I use big.Rat?

Whole code snippet:

package main

import (
"fmt"
"math/big"
)

func main() {

var numerator, denominator, result big.Rat

// These are two ways to get not quite the same big.Rat value:

numerator.SetFloat64(118.5285714285714) // becomes 
118.528571428571396495499357115477

numerator2 := big.NewRat(592642857142857, 5) // becomes 
118.52857142857140 - more accurate than SetFloat64 above!

denominator.SetInt64(8297) // remains 8297.000...

for _, num := range []*big.Rat{, numerator2} {

result.Quo(num, ) // Expected result: 0.01428571428571428

// Show results as fractions.
fmt.Printf("%s over %s is %s\n", num.String(), denominator.String(), 
result.String())

// Show a lot of decimal places.
fmt.Printf("%s over %s is %s\n\n", num.FloatString(30), 
denominator.FloatString(30), result.FloatString(30))

}

// Output:

// 8340706720601115/70368744177664 over 8297/1 is 
8340706720601115/583849470442078208
// 118.528571428571396495499357115477 over 
8297.00 is 0.014285714285714281848318591915

// 592642857142857/5 over 8297/1 is 
592642857142857/41485
// 118.52857142857140 over 
8297.00 is 0.014285714285714282270700253104

}





-- 
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] vim setup for auto go fmt on save.

2016-10-10 Thread 김용빈
Tank you Sander.

I successfully installed and it works well.

Still I want to know simple way though.
If anyone knows about it, please let me know. :)

-- 
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] vim setup for auto go fmt on save.

2016-10-10 Thread Sander van Harmelen
If you want to develop Go in vim, I would strongly suggest to just install and 
use the vim-go package/plugin. It will help you with a lot of stuff, but most 
can be turned of if you don’t want of need it.

Sander


On 10 Oct 2016, at 08:15: 49, 김용빈  wrote:

Hello,

How could I achieve auto go fmt on save in vim? (with 2~3 lines of code)

I don't want install entire plug-in like vim-go. Or is it better to do?

Thank you.
 

-- 
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: Can not install "go-lang-idea-plugin" onto IntelliJ IDEA

2016-10-10 Thread Florin Pățan
I'm happy to hear that it worked out. If you have any issues, feel free to
ping me. I'm also on Gophers Slack or on the Gitter support channel.
Enjoy using the plugin.

On Mon, 10 Oct 2016, 04:15 Yuuki T,  wrote:

> The my download problem had been gone.
>
> I was able to download that via another network place. It was just network
> issue...
>
> Florin-san, thanks!
>
> 2016年10月10日月曜日 8時47分56秒 UTC+9 Florin Pățan:
>
> Hi,
>
>
> It would help if you'd have more information about this.
> I don't have any problems downloading from my current setup but I'm sure
> there are many differences.
> I'll ping the guys from JetBrains as well.
>
>
> Kind regards,
> Florin
>
> On Sunday, October 9, 2016 at 11:05:42 PM UTC+1, Yuuki T wrote:
>
> Currently I can not install "go-lang-idea-plugin" on my IntelliJ
>
> [IntelliJ IDEA] > [Preferences] > [Plugins] >[Browse repositories]
> >[Manage repositories] >
>
> Input, https://plugins.jetbrains.com/plugins/alpha/5047
>
> Then, I tried to install the shown "Go" plugin
>
> However never complete to download bar...
>
> FYI,
> Also I can not download a download file due to server side slow-network(?)
> at the website > https://plugins.jetbrains.com/plugin/5047
> This means it's just network slow problem??
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/golang-nuts/goEovI99HMo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [go-nuts] Turning off nagle's algorithm for http.Client

2016-10-10 Thread Sokolov Yura
Read carefully, and you will not need to do redundant work and write redundant 
code.

It is really here: 
https://github.com/golang/go/blob/release-branch.go1.6/src/net/tcpsock_posix.go

If you don't see it... Then you reading skill is weak.

-- 
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] vim setup for auto go fmt on save.

2016-10-10 Thread 김용빈
Hello,

How could I achieve auto go fmt on save in vim? (with 2~3 lines of code)

I don't want install entire plug-in like vim-go. Or is it better to do?

Thank you.
 

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