[go-nuts] Re: httputil.ReverseProxy adding 100+ ms of latency on localhost - any ideas?

2016-11-18 Thread Tom
The plot thickens.

My attempt to make a minimally-reproducible short example has failed - my 
demo (here ) does not reproduce the 
problem, even though it's mostly copy paste. That leaves the code in my 
original project to blame.

The server-being proxied is simply: *python -m SimpleHTTPServer*

Any recommendations for instrumenting my code to find the bottleneck? I'm 
going to have a quick look for idioms (IIRC Dave Cheney mentioned something 
about a talk he did in europe about HTTPTrace?), otherwise I'm going to 
scatter logging of the current ms.

On Wednesday, 16 November 2016 16:01:50 UTC+11, Tom wrote:
>
> Hi guys,
>
> I've been working on a HTTP reverse proxy that has an auth/authorization 
> function. It all works well, however I have noticed significant additional 
> latency - and I cannot work out why. From what I can tell, me hitting my 
> service from chrome on localhost should work just fine - I have a very 
> beefy machine! (8core 3.4Ghz Amd64)
>
> Anyone have any insights into httputil.ReverseProxy, or have any ideas 
> where to begin?
>
> The method is here: 
> https://github.com/twitchyliquid64/pushtart/blob/master/src/pushtart/webproxy/handler.go#L61
>
> Cheers,
> Tom
>

-- 
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] Best practice when creating temporary files

2016-11-18 Thread Ondrej
I have a tool that generates some HTML and launches a web browser to 
display it. For this to work, I need to save the HTML some place and I also 
need to handle the file afterwards. The app itself doesn't persist - it 
generates the content and exits. There are thus two issues I'm struggling 
with:

1. What is the best place for this? Do I create a folder in 
usr.HomeDir()/.appname/ and place HTML files there? Or do I just create 
tempfiles in os.TempDir? Does it make a difference?
2. How do I clean up? As I said, the app does not persist (so I can't defer 
os.Remove), so either I scan the folder in question (before my HTML 
generation) and remove all files older than, say, a day. Or is that done 
for me by the operating system if I use os.TempDir?

I thought I'd just use os.TempDir and let the OS handle it, but I'm not 
100% sure the OS does clean this up on its own. (This will be used on 
Windows and Macs, maybe Linux.) Any insight on any of these would be 
greatly appreciated.

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.


[go-nuts] Re: Best practice when creating temporary files

2016-11-18 Thread Tamás Gulácsi
2016. november 18., péntek 11:21:23 UTC+1 időpontban Ondrej a következőt 
írta:
>
> I have a tool that generates some HTML and launches a web browser to 
> display it. For this to work, I need to save the HTML some place and I also 
> need to handle the file afterwards. The app itself doesn't persist - it 
> generates the content and exits. There are thus two issues I'm struggling 
> with:
>

Can't the app wait a little bit (maybe a signal from the browser, or a safe 
1 minute), delete the file and then exit?

On modern Linux, /run/user/$(id -u) persists only till the user is logged 
in.

Otherwise, maybe the browser's "Downloads" destination could be used.

-- 
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: http.Client stops working after connected to VPN

2016-11-18 Thread Tamás Gulácsi


2016. november 17., csütörtök 15:52:54 UTC+1 időpontban Diep Pham a 
következőt írta:
>
> I have a program that periodically does a HTTP GET. The simplified codes 
> looks like that. 
>
> ``` 
> package main 
>
> import ( 
> "log" 
> "net/http" 
> "testing" 
> "time" 
> ) 
>
> func TestPlay(t *testing.T) { 
> for { 
> log.Println("starting request") 
> // If I use this, the test will hang forever! 
> // rsp, err := http.Get("http://google.com";) 
> client := http.Client{Timeout: time.Second * 3} 
> rsp, err := client.Get("http://google.com";) 
> if err != nil { 
> t.Fatal(err) 
> } 
> if err = rsp.Body.Close(); err != nil { 
> t.Fatal(err) 
> } 
> log.Println("request finished") 
> log.Println("sleeping...") 
> time.Sleep(time.Second * 1) 
> } 
> } 
> ``` 
>
>
>
> Problem is when a user connects to a VPN network, the request will fails 
> with following error. 
>
> ``` 
> main_test.go:17: Get http://google.com: net/http: request canceled 
> (Client.Timeout exceeded while awaiting headers) 
> ``` 
>
> And if I didn't set timeout in http.Client, it will hang forever! 
>
> So my questions are: 
> - is this normal, expected behavior of http.Client? 
> - what is the best way to handle this? beside just retry the request? 
>


Most probably the network is misconfigured, or just does not allow access 
to http://google.com through the VPN. 
Either allow accessing google.com through the VPN, or configure the network 
to only "use the resources" on the VPN, do not forward all traffic through 
it.

This is not a Go problem, 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] Best practice when creating temporary files

2016-11-18 Thread Jan Mercl
On Fri, Nov 18, 2016 at 11:21 AM Ondrej  wrote:

Not sure if it's correct, just an idea (error handling elided):

func main() {
...
exec.Cmd(browser, pathName).Start()
syscal.Unlink(pathName)
}

The temp file in pathName will be deleted when the browser closes the file.

-- 

-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] Re: http.Client stops working after connected to VPN

2016-11-18 Thread Diep Pham
Tamás Gulácsi wrote:
> Either allow accessing google.com through the VPN, or configure the
> network to only "use the resources" on the VPN, do not forward all
> traffic through it.

Maybe I didn't describe the problem clearly. VPN configuration is OK, I
can connect to Google normally. Only the HTTP request happens right
after VPN connection (or maybe during VPN connection) fails. If I use
default HTTP client, it will freeze forever. If I set timeout to 10s, it
will hang for 10s and returns the "net/http: request canceled
(Client.Timeout exceeded while awaiting headers" error.

-- 
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] Best practice when creating temporary files

2016-11-18 Thread Tamás Gulácsi


2016. november 18., péntek 12:21:48 UTC+1 időpontban Jan Mercl a következőt 
írta:
>
> On Fri, Nov 18, 2016 at 11:21 AM Ondrej > 
> wrote:
>
> Not sure if it's correct, just an idea (error handling elided):
>
> func main() {
> ...
> exec.Cmd(browser, pathName).Start()
> syscal.Unlink(pathName)
> }
>
> The temp file in pathName will be deleted when the browser closes the file.
>
> -- 
>
> -j
>

Only on normal fs, not on Windows (or you have to open the file with 
*FILE_SHARE_DELETE* flag...)

-- 
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: http.Client stops working after connected to VPN

2016-11-18 Thread Tamás Gulácsi


2016. november 18., péntek 12:25:15 UTC+1 időpontban Diep Pham a következőt 
írta:
>
> Tamás Gulácsi wrote: 
> > Either allow accessing google.com through the VPN, or configure the 
> > network to only "use the resources" on the VPN, do not forward all 
> > traffic through it. 
>
> Maybe I didn't describe the problem clearly. VPN configuration is OK, I 
> can connect to Google normally. Only the HTTP request happens right 
> after VPN connection (or maybe during VPN connection) fails. If I use 
> default HTTP client, it will freeze forever. If I set timeout to 10s, it 
> will hang for 10s and returns the "net/http: request canceled 
> (Client.Timeout exceeded while awaiting headers" error. 
>

In this casee you should just retry: the VPN transition may mean that the 
previously resolved DNS address of google.com has changed, or the whole 
routing has changed, and you have to start over. 

-- 
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] Avoiding function call overhead in packages with go+asm implementations

2016-11-18 Thread Aram Hăvărneanu
On Fri, Nov 18, 2016 at 4:41 AM, Caleb Spare  wrote:
> Aram gave me the idea of using //go:linkname as a hacky workaround;
> this doesn't work within a single package

What do you mean exactly? It works here, in fact, I use this.

-- 
Aram Hăvărneanu

-- 
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: http.Client stops working after connected to VPN

2016-11-18 Thread Diep Pham
Tamás Gulácsi wrote:
> In this casee you should just retry: the VPN transition may mean that
> the previously resolved DNS address of google.com has changed, or the
> whole routing has changed, and you have to start over.

Well, the program do many sequential HTTP calls. I guess I will have to
wrap them all in a retry-n-number-of-times function. But is it expected
behavior of a HTTP client when network change?

-- 
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: Help! Can't get cgo to work

2016-11-18 Thread hhzguo
I ran into the same problem.  in one of my go file, I have: 

//#cgo CFLAGS: -I/usr/include/libnl3
/*
#include 



However, when I try to build, I got the following error: ( I have 
libnl-3-dev, libnl-genl-3-dev installed and the netlink/netlink.h file is 
at /usr/include/libnl3/ directory. netlink.h file does include some other 
header files like
 #include 
#include 
#include --> The same directory as "netlink/netlink.h" 
file


+ go install -gcflags '' -ldflags ' -X 
k8s.io/kubernetes/pkg/version.buildDate=2016-11-18T06:14:04Z -X 
k8s.io/kubernetes/pkg/version.gitCommit=a26530bfce8126450e4ad0faab222046ce0953f3
 
-X k8s.io/kubernetes/pkg/version.gitTreeState=dirty -X 
k8s.io/kubernetes/pkg/version.gitVersion=v1.1.0-alpha.1.16011+a26530bfce8126-dirty
 
-X k8s.io/kubernetes/pkg/version.gitMajor=1 -X 
k8s.io/kubernetes/pkg/version.gitMinor=1+' k8s.io/kubernetes/cmd/kubelet 
k8s.io/kubernetes/cmd/kubemark k8s.io/kubernetes/cmd/hyperkube 
k8s.io/kubernetes/cmd/gendocs k8s.io/kubernetes/cmd/genkubedocs 
k8s.io/kubernetes/cmd/genman k8s.io/kubernetes/cmd/genyaml 
k8s.io/kubernetes/cmd/mungedocs k8s.io/kubernetes/cmd/genswaggertypedocs 
k8s.io/kubernetes/cmd/linkcheck 
k8s.io/kubernetes/examples/k8petstore/web-server/src 
k8s.io/kubernetes/federation/cmd/genfeddocs 
k8s.io/kubernetes/vendor/github.com/onsi/ginkgo/ginkgo
# k8s.io/kubernetes/vendor/github.com/google/seesaw/netlink
vendor/github.com/google/seesaw/netlink/cfuncs.go:19:29: fatal error: 
netlink/netlink.h: No such file or directory
 #include 
 ^
compilation terminated.



On Friday, July 19, 2013 at 1:37:27 PM UTC-7, john...@gmail.com wrote:

> I'm trying to build an interface for the Swiss Ephemeris package. So far, 
> I've got the original compiled to both a .a and a .so, and I've moved the 
> two header files I need into the same directory as the .go file. I've also 
> stuck the .a (but not the .so) into pkg/darwin_amd64.
>
> Here's the source:
>
> // swephint is the interface to the Swiss Ephemeris: see the Swiss 
> Ephemeris documentation
> // for copyright information.
>
> package swephint
>
> /*
>
> #cgo LDFLAGS: -llibswe
>
> #import "swephexp.h"
>
> */
> import "C"
> import "unsafe"
>
> func SetEphPath(path string) {
> cpath := C.CString(path)
> defer C.free(unsafe.Pointer(cpath))
> C.swe_set_ephe_path(cpath)
> }
>
> This is an almost direct copy from the cgo article.
>
> What's happening is:
>
> jhrothjr:src johnroth$ go install swephint
> # swephint
> ld: library not found for -llibswe
> collect2: ld returned 1 exit status
>
> I've already tried using -L for the directory where the .a and .so were 
> originally compiled to. It also doesn't seem to make any difference whether 
> I say -llibswe or -llibswe.a
>
> As you might guess, I'm a relative novice in unix-style development tools.
>
> Any ideas? Thanks in advance
>
> 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] where is my lib? cgo and c libraries

2016-11-18 Thread hhzguo
"Go means to make life easier, however, it goes other direction.

On Saturday, April 6, 2013 at 10:43:01 AM UTC-7, Peter Kleiweg wrote:
>
> Op zaterdag 6 april 2013 15:52:05 UTC+2 schreef Ian Lance Taylor het 
> volgende:
>
> Now that we use external linking, this is going to be pushed into the 
>>
>
> What's that, external linking?
>  
>
>> space of the external linker.  External linkers historically do not 
>> add -L options to the shared library search path, because it leads to 
>> a problem that is the reverse of the one you cite.  At runtime, the 
>> program can wind up searching many directories unnecessarily.  This is 
>> particularly bad when those directories are mounted using NFS or FUSE 
>> or some such technology. 
>>
>> From Go's perspective it would be easy to say "whenever we pass a -L 
>> option to the system linker, also pass a -Wl,-rpath option."  It would 
>> also be easy for the gcc driver to do this, and it would be easy for 
>> an ELF linker to do this.  The question, then, is whether the go tool 
>> should behave differently from those older tools. 
>>
>
> Yes, do it differently. Go was meant to make life easier. It doesn't use 
> download, extract, configure, make, make install, it uses go get, which is 
> enough most of the time. I say, make it work too in those cases where now 
> it doesn't work because of missing paths to C libraries.
>  
> For the user it's simple: a program should work, or it is useless. So, 
> make it work, without the need of special actions by the user.
>
> So yes, pass that option to the linker. If it is not necessary, the linker 
> drops it anyway. If it is necessary to run the program, than add it. 
>
>
> Ideally pkg-config would provide the right answer.  It does have 
>> support for this.  So one question to ask would be why pkg-config 
>> isn't doing the right thing for the library in question. 
>>
>
> Because it is also used to build binary distributions of programs?
>
>

-- 
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] (GUI) Qt binding which supports Windows / macOS / Linux / Android / iOS / Sailfish OS / Raspberry Pi

2016-11-18 Thread therecipe
It's intended to be build against Qt 5.7.
And I think Qt 5.6.2 works also (with some errors/warnings during the setup)
I may add backward compatibility in the future, but it's not planned yet.

I use this script to get Qt 5.7 on trusty, if you want to link against 
system libs.
https://github.com/therecipe/qt/blob/master/internal/ci/linux.sh

Otherwise I would recommend to try the official pre-build packages, which 
will also allow stand alone deployments of you application.

Am Freitag, 18. November 2016 02:29:20 UTC+1 schrieb howar...@gmail.com:
>
> What version of QT is it intended to be built against? I get
> therecipe/qt/core/core.cpp:9:30: fatal error: QAbstractAnimation: No such 
> file or directory
> when I try to build against it, or when trying to build the renderer 
> example.
>
> qt5-default says it is 5.5.1+dfsg-16ubuntu7.2 and qtdeclarative5-dev 
> is 5.5.1-2ubuntu6
>
> I am building on Ubuntu 16.04.1 LTS.
>
> Howard
>

-- 
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] Short Variable Declaration Question

2016-11-18 Thread Terry McKenna
Hi Guys,

I am reading "The Go Programming Language": Donovan, Kernighan (pg.31):

"One subtle but important point: a short variable declaration does not 
necessarily declare all the variables on the its left-hand side. If some of 
them were already declared in the same lexical block then then the short 
variable declaration acts like an assignment to those variables."

I get that.

"In the code below, the first statement declares both in and err. The 
second declares out but only assigns a value to the existing err variable:

in, err := os.Open(infile)
// ...
out, err := os.Create(outfile)

A short variable declaration must declare at least one new variable "

My question is, the second declaration (out, err := os.Create(outfile)), is 
declaring a new var so why is the value from "os.Create(outfile)" not 
assigned to out? I understand that err is updated but again, why is no 
value assigned to the variable out?

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] Short Variable Declaration Question

2016-11-18 Thread Ian Lance Taylor
On Fri, Nov 18, 2016 at 7:02 AM, Terry McKenna  wrote:
>
> I am reading "The Go Programming Language": Donovan, Kernighan (pg.31):
>
> "One subtle but important point: a short variable declaration does not
> necessarily declare all the variables on the its left-hand side. If some of
> them were already declared in the same lexical block then then the short
> variable declaration acts like an assignment to those variables."
>
> I get that.
>
> "In the code below, the first statement declares both in and err. The second
> declares out but only assigns a value to the existing err variable:
>
> in, err := os.Open(infile)
> // ...
> out, err := os.Create(outfile)
>
> A short variable declaration must declare at least one new variable "
>
> My question is, the second declaration (out, err := os.Create(outfile)), is
> declaring a new var so why is the value from "os.Create(outfile)" not
> assigned to out? I understand that err is updated but again, why is no value
> assigned to the variable out?

It does assign a value to the variable out.

I think the book is trying to stress that it declares out but does not
declare err.  I agree that the sentence seems to imply that it does
not assign a value to out, but in fact it does both declare out and
assign a value to it.

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] Re: Best practice when creating temporary files

2016-11-18 Thread Val
Obtain a new temp file :
  tmpfile, err := ioutil.TempFile("", "")

Obtain a new temp dir :
  dir, err := ioutil.TempDir("", "")

I suggest you don't bother with cleanup.  It should work on any OS.

On Friday, November 18, 2016 at 11:21:23 AM UTC+1, Ondrej wrote:
>
> I have a tool that generates some HTML and launches a web browser to 
> display it. For this to work, I need to save the HTML some place and I also 
> need to handle the file afterwards. The app itself doesn't persist - it 
> generates the content and exits. There are thus two issues I'm struggling 
> with:
>
> 1. What is the best place for this? Do I create a folder in 
> usr.HomeDir()/.appname/ and place HTML files there? Or do I just create 
> tempfiles in os.TempDir? Does it make a difference?
> 2. How do I clean up? As I said, the app does not persist (so I can't 
> defer os.Remove), so either I scan the folder in question (before my HTML 
> generation) and remove all files older than, say, a day. Or is that done 
> for me by the operating system if I use os.TempDir?
>
> I thought I'd just use os.TempDir and let the OS handle it, but I'm not 
> 100% sure the OS does clean this up on its own. (This will be used on 
> Windows and Macs, maybe Linux.) Any insight on any of these would be 
> greatly appreciated.
>
> 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] Short Variable Declaration Question

2016-11-18 Thread Ian Davis
I think the sentence is supposed to read something like this:



"The second declares out (and assigns to it as before) but only assigns
a value to the existing err variable (without declaring it)"




On Fri, Nov 18, 2016, at 03:02 PM, Terry McKenna wrote:

> Hi Guys,

> 

> I am reading "The Go Programming Language": Donovan, Kernighan
> (pg.31):
> 

> "One subtle but important point: a short variable declaration does not
> necessarily declare all the variables on the its left-hand side. If
> some of them were already declared in the same lexical block then then
> the short variable declaration acts like an assignment to those
> variables."
> 

> I get that.

> 

> "In the code below, the first statement declares both in and err. The
> second declares out but only assigns a value to the existing err
> variable:
> 

> in, err := os.Open(infile)

> // ...

> out, err := os.Create(outfile)

> 

> A short variable declaration must declare at least one new
> variable "
> 

> My question is, the second declaration (out, err :=
> os.Create(outfile)), is declaring a new var so why is the value from
> "os.Create(outfile)" not assigned to out? I understand that err is
> updated but again, why is no value assigned to the variable out?
> 

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


RE: [go-nuts] template Inheritance

2016-11-18 Thread dhal.asitk
Hi,

You won’t find everything in Jinja  exactly in Golang.
If you want to do in Golang, you can refer here.
https://hackernoon.com/golang-template-2-template-composition-and-how-to-organize-template-files-4cb40bcdf8f6#.3ljf0fsjy

You can refer here also.
https://github.com/jmoiron/jigo
These guys have attempted to imitate jinja in Golang.

Warm Regards,
Asit Dhal
http://asit-dhal.github.io/

From: Manlio Perillo
Sent: Wednesday, November 16, 2016 17:26
To: golang-nuts
Subject: [go-nuts] template Inheritance

I'm trying to use the new block action in the template package but I'm not sure 
to understand how it should be use.

What I would like to do is something like template inheritance support in Jinja 
templating:
http://jinja.pocoo.org/docs/dev/templates/#template-inheritance


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.

-- 
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] http2 client/server reversal performance

2016-11-18 Thread jonathan . gaillard
Forgot to note that if I flip the coffee around to the "normal" case where the 
serveconn is done by the server the speed is as expected over WAN. 
Are there some internal settings different for the client vs server?

-- 
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: template Inheritance

2016-11-18 Thread Manlio Perillo
Il giorno mercoledì 16 novembre 2016 17:26:37 UTC+1, Manlio Perillo ha 
scritto:
>
> I'm trying to use the new block action in the template package but I'm not 
> sure to understand how it should be use.
>
> What I would like to do is something like template inheritance support in 
> Jinja templating:
> http://jinja.pocoo.org/docs/dev/templates/#template-inheritance
>
>
>
I wrote this package:
https://gist.github.com/anonymous/62fe24c6f6cf865bf5d257d753db312f

It implements a template loader; I adapted the code from
https://github.com/golang/gddo

Is this useful enough to be implemented in golang.org/x/ subrepository?

Another question is: what is the reason why the template engine does not 
support the
{{include "name"}} action?


Thanks (and also thanks to Asit for the response)
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] Re: Short Variable Declaration Question

2016-11-18 Thread Terry McKenna
Alright.

Thanks guys.

On Friday, November 18, 2016 at 10:22:06 AM UTC-5, Terry McKenna wrote:
>
> Hi Guys,
>
> I am reading "The Go Programming Language": Donovan, Kernighan (pg.31):
>
> "One subtle but important point: a short variable declaration does not 
> necessarily declare all the variables on the its left-hand side. If some of 
> them were already declared in the same lexical block then then the short 
> variable declaration acts like an assignment to those variables."
>
> I get that.
>
> "In the code below, the first statement declares both in and err. The 
> second declares out but only assigns a value to the existing err variable:
>
> in, err := os.Open(infile)
> // ...
> out, err := os.Create(outfile)
>
> A short variable declaration must declare at least one new variable "
>
> My question is, the second declaration (out, err := os.Create(outfile)), 
> is declaring a new var so why is the value from "os.Create(outfile)" not 
> assigned to out? I understand that err is updated but again, why is no 
> value assigned to the variable out?
>
> 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.


[go-nuts] macro support in text/template

2016-11-18 Thread Manlio Perillo
Hi.

I'm trying to implement HTML form support in Go,
Forms are one of the most complex components to implement in a web 
application.

Here is a simple form with only two text field, using bootstrap:
https://gist.github.com/anonymous/5a21a22e6d5fd9d0f745c1700c634b54

Writing the HTML code by hand is unreasonable, and having the form to be 
automatically generated from Go source code is not flexible.
There are a lot of details for the form UI that needs to be specified.

I would like to have support for macros in html/template.
As an example, something like this:
https://gist.github.com/anonymous/6a5f0165df14677e277d7d2b53294882

When parsing the macro action {{% func  %}}, the verbatim text for 
 will be passed to fun.
The function func will parse, at template parsing time, the text and will 
return the transformed text that will be then processed by parser.

Is this feasible?


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.


Re: [go-nuts] macro support in text/template

2016-11-18 Thread Ian Lance Taylor
On Fri, Nov 18, 2016 at 11:50 AM, Manlio Perillo
 wrote:
>
> I'm trying to implement HTML form support in Go,
> Forms are one of the most complex components to implement in a web
> application.
>
> Here is a simple form with only two text field, using bootstrap:
> https://gist.github.com/anonymous/5a21a22e6d5fd9d0f745c1700c634b54
>
> Writing the HTML code by hand is unreasonable, and having the form to be
> automatically generated from Go source code is not flexible.
> There are a lot of details for the form UI that needs to be specified.
>
> I would like to have support for macros in html/template.
> As an example, something like this:
> https://gist.github.com/anonymous/6a5f0165df14677e277d7d2b53294882
>
> When parsing the macro action {{% func  %}}, the verbatim text for
>  will be passed to fun.
> The function func will parse, at template parsing time, the text and will
> return the transformed text that will be then processed by parser.
>
> Is this feasible?

It shouldn't be necessary to add a programming language to templates,
since you already have a programming language to use, namely Go
itself.  This doesn't necessarily mean generating HTML in Go--the Go
function can simply be a text transformation on its arguments.

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] macro support in text/template

2016-11-18 Thread Manlio Perillo
Il giorno venerdì 18 novembre 2016 21:23:38 UTC+1, Ian Lance Taylor ha 
scritto:
>
> On Fri, Nov 18, 2016 at 11:50 AM, Manlio Perillo 
> > wrote: 
> > 
> > I'm trying to implement HTML form support in Go, 
> > Forms are one of the most complex components to implement in a web 
> > application. 
> > 
> > Here is a simple form with only two text field, using bootstrap: 
> > https://gist.github.com/anonymous/5a21a22e6d5fd9d0f745c1700c634b54 
> > 
> > Writing the HTML code by hand is unreasonable, and having the form to be 
> > automatically generated from Go source code is not flexible. 
> > There are a lot of details for the form UI that needs to be specified. 
> > 
> > I would like to have support for macros in html/template. 
> > As an example, something like this: 
> > https://gist.github.com/anonymous/6a5f0165df14677e277d7d2b53294882 
> > 
> > When parsing the macro action {{% func  %}}, the verbatim text for 
> >  will be passed to fun. 
> > The function func will parse, at template parsing time, the text and 
> will 
> > return the transformed text that will be then processed by parser. 
> > 
> > Is this feasible? 
>
> It shouldn't be necessary to add a programming language to templates, 
> since you already have a programming language to use, namely Go 
> itself.  This doesn't necessarily mean generating HTML in Go--the Go 
> function can simply be a text transformation on its arguments. 
>
>
It's true that I can use raw strings, e.g (not tested).

{{ field "sku" . `SKU

{{ .Errors.sku }}`
}}

However there are two problems:
1) I need to parse the argument each time the function is called
2) the text returned by the function will not be parsed again by the 
template parser.


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.


Re: [go-nuts] macro support in text/template

2016-11-18 Thread mhhcbon
Solved that issue by creating components on server side, 
they hold a reference to the template, their block name, their 
configuration,
so they can expose a render method to consume within the view.

https://github.com/mh-cbon/mdl-go-components



On Friday, November 18, 2016 at 10:23:21 PM UTC+1, Manlio Perillo wrote:
>
> Il giorno venerdì 18 novembre 2016 21:23:38 UTC+1, Ian Lance Taylor ha 
> scritto:
>>
>> On Fri, Nov 18, 2016 at 11:50 AM, Manlio Perillo 
>>  wrote: 
>> > 
>> > I'm trying to implement HTML form support in Go, 
>> > Forms are one of the most complex components to implement in a web 
>> > application. 
>> > 
>> > Here is a simple form with only two text field, using bootstrap: 
>> > https://gist.github.com/anonymous/5a21a22e6d5fd9d0f745c1700c634b54 
>> > 
>> > Writing the HTML code by hand is unreasonable, and having the form to 
>> be 
>> > automatically generated from Go source code is not flexible. 
>> > There are a lot of details for the form UI that needs to be specified. 
>> > 
>> > I would like to have support for macros in html/template. 
>> > As an example, something like this: 
>> > https://gist.github.com/anonymous/6a5f0165df14677e277d7d2b53294882 
>> > 
>> > When parsing the macro action {{% func  %}}, the verbatim text 
>> for 
>> >  will be passed to fun. 
>> > The function func will parse, at template parsing time, the text and 
>> will 
>> > return the transformed text that will be then processed by parser. 
>> > 
>> > Is this feasible? 
>>
>> It shouldn't be necessary to add a programming language to templates, 
>> since you already have a programming language to use, namely Go 
>> itself.  This doesn't necessarily mean generating HTML in Go--the Go 
>> function can simply be a text transformation on its arguments. 
>>
>>
> It's true that I can use raw strings, e.g (not tested).
>
> {{ field "sku" . `SKU
> 
> {{ .Errors.sku }}`
> }}
>
> However there are two problems:
> 1) I need to parse the argument each time the function is called
> 2) the text returned by the function will not be parsed again by the 
> template parser.
>
>
> 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] Re: http2 client/server reversal performance

2016-11-18 Thread jonathan . gaillard
Actually it turns out that the tests from the http2 client writing into a 
request and the http2 server reading from the request is slow. That is 
despite whether the http2 server is on the server end of the tcp connection 
or the client end. This is between two machines with a 55ms latency. Scp is 
fast over the two machines in both directions. As is the test over two 
machines on a LAN.
I've tried changing the following constants in the http2 code, 
handlerChunkWriteSize, transportDefaultStreamMinRefresh, 
defaultMaxReadFrameSize, initialWindowSize, initialHeaderTableSize and 
initialMaxFrameSize to no effect.

On Friday, November 18, 2016 at 9:17:57 AM UTC-8, jonathan...@gmail.com 
wrote:
>
> Forgot to note that if I flip the coffee around to the "normal" case where 
> the serveconn is done by the server the speed is as expected over WAN. 
> Are there some internal settings different for the client vs server?

-- 
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] Where to start to learn about Go compiler and others low level part?

2016-11-18 Thread nvcnvn
All I ever do is some simple web applications or kind of microservice for CMS 
stuff.
Now I want to process to something deeper as a programmer. Everytime reading Go 
core team discussion about compiler, GC... I know that serious deep and 
complicate stuff. Now I have plenty of time and want to learn about them but 
don't know where to start.
My goal is spending next year to learn and hope can contribute even just a 
small bit to the project.
Please show me the paths to get there.

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.


[go-nuts] Avoiding function call overhead in packages with go+asm implementations

2016-11-18 Thread Damian Gryski
This is one of those tricks that should be in a "best practices for writing asm 
with Go" document.

Maybe we should start one on the wiki? Including things like "common build tags 
for disabling asm" and the like.

Damian

-- 
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 unix time from a json stream is of different format

2016-11-18 Thread Sathish VJ
I'm trying to unmarshal unix time from a json stream.  Why is my custom 
type UnixTime printing a completely different format of the time? 
 Shouldn't it be just a normal time.Time format?

type UnixTime time.Time

func (t *UnixTime) UnmarshalJSON(b []byte) error {
ts, _ := strconv.Atoi(string(b))

fmt.Println("time:", time.Unix(int64(ts), 0))
*t = UnixTime(time.Unix(int64(ts), 0))
fmt.Println("Unixtime:", *t)

return nil
}

//output

time: 2016-11-19 05:58:58 + UTC
Unixtime: {63615131938 0 0x196f20}




Play link (full code): https://play.golang.org/p/FfhBI5lq2K

-- 
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 unix time from a json stream is of different format

2016-11-18 Thread Dave Cheney
UnixTime and time.Time are different types with different method sets. UnixTime 
is not a subclass or a child type of time.Time as there is no such thing as 
inheritance in go. 

Try printing this value. 

   time.Time(*t)

Dave

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