Re: [go-nuts] Re: Guidance on exposing functionality

2017-06-06 Thread Michael Jones
sometimes you can write the simple one in terms of the advanced one. when
you can do that, it makes them better and also educational.

On Tue, Jun 6, 2017 at 7:09 PM, peterGo  wrote:

> M2,
>
> The Go strconv package (https://golang.org/pkg/strconv/) contains the
> simple forms Atoi and Itoa and the complex forms ParseInt and FormatInt. In
> the documentation for each function refer to the alternate form.
>
> Peter
>
> On Tuesday, June 6, 2017 at 3:56:43 PM UTC-4, M2 wrote:
>
>> I need to expose 2 ways of doing the same thing.
>>
>> - The first way is very simple, always does the right thing and is
>> impossible to use improperly. It is expected to be used by the majority of
>> users.
>> - The second one can be used improperly but offers more flexibility. It
>> is expected to be used by a minority of users.
>>
>> What is the idiomatic way in go to expose them?
>> 1). Have them both in the same package since they do the same thing and
>> just document them properly.
>> 2). Have them in different packages with one named .../unsafe/myPackage/
>> and one named .../safe/myPackage/ then have a third package that has all
>> the private stuff that will be accessed by both unsafe and safe package
>>
>> 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.
>



-- 
Michael T. Jones
michael.jo...@gmail.com

-- 
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: mixed C / Go debugging

2017-06-06 Thread brainman
It would be useful if you provide complete instructions of what you did, so 
we could at least be able to reproduce it here. Including complete source 
code and description of environment and tools you use. Thank you.

Alex

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


[go-nuts] Re: letsencrypt, localhost and autocert

2017-06-06 Thread winlin
There is a library base on lego and letsencrypt 
project: 
https://github.com/ossrs/go-oryx-lib/blob/master/https/example_test.go#L33
And there is a server as an example for that 
library: https://github.com/ossrs/go-oryx/blob/develop/httpx-static/main.go#L174


On Wednesday, June 7, 2017 at 1:07:16 AM UTC+8, Sankar wrote:
>
> Hi
>
> I saw the tweet https://twitter.com/mholt6/status/848704744474292224 and 
> decided to try out the code
>
> log.Fatal(http.Serve(autocert.NewListener("mydomain.com 
> "), handler)) 
>
> but when I try to visit: https://localhost:443, I get an error on the 
> server console as: server name component count invalid
>
> Is there any detailed documentation on how to get letsencrypt working with 
> golang ?
>
> I am using go 1.8.3
>
> Google gave me https://github.com/golang/go/issues/17053 , but I am not 
> able to understand if the letsencrypt support is fully landed or not. Can 
> anyone point me to docs and best practices for testing at localhost and 
> deploying at production, with https and letsencrypt ? 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] mixed C / Go debugging

2017-06-06 Thread Alain Mellan
Hi,

I need to have a Go application wrapped in a DLL with a thin C layer so 
that I can load the .dll (I'm on Windows) from a C/C++ application. What 
are my options for debugging the Go code?

When I load my app from gdb, it seems the Go code is a black box, and dlv 
does not seem to be able to attach properly to the process that is running 
app + go dll.

Am I missing something? Any suggestions?

-- alain.

-- 
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: In-memory secondary index

2017-06-06 Thread James Pettyjohn
Thanks Dragos, I had looked at that one earlier but I was hoping for 
something that was more implicit to a struct definition.

Something like:

type StructIndex struct{}
func NewStructIndex([]Interface{}) *StructIndex{}
func (si *StructIndex) Get(k string, v interface{}) []interface{}

Implementation would probably include an Index(fieldName) call as well or 
it could create one based on heuristics.

I could put that together using maps or an radix-tree library, but I know I 
would not take advantage of everything I library on the matter would.

In the mean time I'm trying widely different approach that may fit in my 
scenario with cayley. 

On Monday, June 5, 2017 at 4:37:59 PM UTC-7, Dragos Harabor wrote:
>
> Something like this?
> https://github.com/hashicorp/go-memdb
>
> Though it may have more features than you need. Or features that you don't 
> yet know you want :-)
>
> On Monday, June 5, 2017 at 3:28:33 AM UTC-7, James Pettyjohn wrote:
>>
>> I'm loading a set of structs in memory and will be frequently using them 
>> throughout the lifetime of the application and doing frequent 'queries' 
>> against the set to get those where certain fields have certain values.
>>
>> Are there are any native go libraries which do this kind of sort of 
>> "secondary index" on in memory data structures?
>>
>>

-- 
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] Save file handle into struct

2017-06-06 Thread Tong Sun
On Tue, Jun 6, 2017 at 5:50 PM, Sebastien Binet  wrote:

> like so:
> https://play.golang.org/p/s-7h25c5jW
>

duh. 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: Guidance on exposing functionality

2017-06-06 Thread peterGo
M2,

The Go strconv package (https://golang.org/pkg/strconv/) contains the 
simple forms Atoi and Itoa and the complex forms ParseInt and FormatInt. In 
the documentation for each function refer to the alternate form.

Peter

On Tuesday, June 6, 2017 at 3:56:43 PM UTC-4, M2 wrote:
>
> I need to expose 2 ways of doing the same thing.
>
> - The first way is very simple, always does the right thing and is 
> impossible to use improperly. It is expected to be used by the majority of 
> users.
> - The second one can be used improperly but offers more flexibility. It is 
> expected to be used by a minority of users.
>
> What is the idiomatic way in go to expose them?
> 1). Have them both in the same package since they do the same thing and 
> just document them properly.
> 2). Have them in different packages with one named .../unsafe/myPackage/ 
> and one named .../safe/myPackage/ then have a third package that has all 
> the private stuff that will be accessed by both unsafe and safe package
>
> 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: Guidance on exposing functionality

2017-06-06 Thread M2
Thanks for taking the time to respond. This is how I was thinking also.

I am trying to gather what is the most common approach in Go community to 
avoid "surprising" my users. If anyone has an opinion please feel free to 
chime in.

Thanks again

On Tuesday, June 6, 2017 at 1:43:57 PM UTC-7, Matt Layher wrote:
>
> Approach number one is the correct way, IMO.
>
> That's what I've always done: 
> https://godoc.org/github.com/mdlayher/netlink#Conn.Execute.
>
> - Matt
>
> On Tuesday, June 6, 2017 at 3:56:43 PM UTC-4, M2 wrote:
>>
>> I need to expose 2 ways of doing the same thing.
>>
>> - The first way is very simple, always does the right thing and is 
>> impossible to use improperly. It is expected to be used by the majority of 
>> users.
>> - The second one can be used improperly but offers more flexibility. It 
>> is expected to be used by a minority of users.
>>
>> What is the idiomatic way in go to expose them?
>> 1). Have them both in the same package since they do the same thing and 
>> just document them properly.
>> 2). Have them in different packages with one named .../unsafe/myPackage/ 
>> and one named .../safe/myPackage/ then have a third package that has all 
>> the private stuff that will be accessed by both unsafe and safe package
>>
>> 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] Save file handle into struct

2017-06-06 Thread Sebastien Binet
like so:
https://play.golang.org/p/s-7h25c5jW

On Tue, Jun 6, 2017 at 11:47 PM, Tong Sun  wrote:

> Hi,
>
> How to save the file handle into struct?
>
> So in this file,
> https://play.golang.org/p/SWnJ4TZyTu
>
> If I change line 34 "ft.f" to just "f", it will at least pass gofmt. Else,
> I'll get
>
> 34:5: expected identifier on left side of :=
>
>
> However, what if I want to save the opened file handle into struct?
>
> 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] Save file handle into struct

2017-06-06 Thread Tong Sun
Hi, 

How to save the file handle into struct?

So in this file, 
https://play.golang.org/p/SWnJ4TZyTu

If I change line 34 "ft.f" to just "f", it will at least pass gofmt. Else, 
I'll get

34:5: expected identifier on left side of :=


However, what if I want to save the opened file handle into struct? 

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: Guidance on exposing functionality

2017-06-06 Thread Matt Layher
Approach number one is the correct way, IMO.

That's what I've always 
done: https://godoc.org/github.com/mdlayher/netlink#Conn.Execute.

- Matt

On Tuesday, June 6, 2017 at 3:56:43 PM UTC-4, M2 wrote:
>
> I need to expose 2 ways of doing the same thing.
>
> - The first way is very simple, always does the right thing and is 
> impossible to use improperly. It is expected to be used by the majority of 
> users.
> - The second one can be used improperly but offers more flexibility. It is 
> expected to be used by a minority of users.
>
> What is the idiomatic way in go to expose them?
> 1). Have them both in the same package since they do the same thing and 
> just document them properly.
> 2). Have them in different packages with one named .../unsafe/myPackage/ 
> and one named .../safe/myPackage/ then have a third package that has all 
> the private stuff that will be accessed by both unsafe and safe package
>
> 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] Guidance on exposing functionality

2017-06-06 Thread M2
I need to expose 2 ways of doing the same thing.

- The first way is very simple, always does the right thing and is 
impossible to use improperly. It is expected to be used by the majority of 
users.
- The second one can be used improperly but offers more flexibility. It is 
expected to be used by a minority of users.

What is the idiomatic way in go to expose them?
1). Have them both in the same package since they do the same thing and 
just document them properly.
2). Have them in different packages with one named .../unsafe/myPackage/ 
and one named .../safe/myPackage/ then have a third package that has all 
the private stuff that will be accessed by both unsafe and safe package

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: Is there any golang package available for building mongodb query from plain logic expression string or URL?

2017-06-06 Thread Ray Yang
Thanks Nathan. It has builder part but I need both parser and builder.

It looks that I have to build the wheel or at least part of it.

On Monday, June 5, 2017 at 11:16:36 PM UTC-7, Nathan Kerr wrote:
>
> I haven't tried it, but https://github.com/jhsx/qm might be useful.

-- 
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] letsencrypt, localhost and autocert

2017-06-06 Thread Andy Balholm
What it boils down to is that your server tries to get a certificate for 
whatever name is in the URL. But Let’s Encrypt won’t issue a certificate for 
localhost, for various reasons—not the least of which is that a certificate for 
localhost makes as much sense as having a photo ID that says “Me” for the name.

Andy

-- 
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] letsencrypt, localhost and autocert

2017-06-06 Thread 'Axel Wagner' via golang-nuts
tl;dr: You need a) a publicly routed IP address (either IPv4 or IPv6 is
fine), b) a publicly resolvable domain that points to that IP address and
c) actually point your client (browser) to that domain.

Long explanation:

The HTTP client will use SNI to tell the server the domain it needs a cert
for. The autocert package will then check that against the provided
HostPolicy (in the case of NewListener, that means "is it one of the listed
domains") and tell LetsEncrypt that it wants a certificate for that domain.
LetsEncrypt will then verify, that you actually own that domain and the
corresponding key (thus the need for a publicly resolvable Domain.
LetsEncrypt can't verify that you are "localhost"). There are multiple
challenges for that (I believe there is one that uses DNS and one that uses
SNI?), autocert implements only one the latter (I think) and tells
LetsEncrypt which. As it doesn't implement the DNS based challenge,
LetsEncrypt needs to resolve the domain to an IP and make a connection to
it (thus the need for a publicly routed IP address) to verify, that there
actually is someone with the correct key sitting behind it. That'll be
autocert. Finally, if all that works, LetsEncrypt issues a certificate for
that domain and gives it to your server; again, the autocert package
handles the receiving and caching of that cert. Once it has the cert, it
will finish the TLS handshake with the HTTP client and you have a valid
connection. Future connections will just reuse the cached certificate,
given that the client sends the same domain via SNI.

Hope that helps. It's quite a bit of complexity behind that one line of
code; but if you actually fulfill above requirements a, b and c, it will be
a total breeze to get good, strong certificates for however many domains
you need :)

On Tue, Jun 6, 2017 at 7:07 PM, Sankar  wrote:

> Hi
>
> I saw the tweet https://twitter.com/mholt6/status/848704744474292224 and
> decided to try out the code
>
> log.Fatal(http.Serve(autocert.NewListener("mydomain.com
> "), handler))
>
> but when I try to visit: https://localhost:443, I get an error on the
> server console as: server name component count invalid
>
> Is there any detailed documentation on how to get letsencrypt working with
> golang ?
>
> I am using go 1.8.3
>
> Google gave me https://github.com/golang/go/issues/17053 , but I am not
> able to understand if the letsencrypt support is fully landed or not. Can
> anyone point me to docs and best practices for testing at localhost and
> deploying at production, with https and letsencrypt ? 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: Golang, SQL and ORM avoidance techniques

2017-06-06 Thread Ren Thraysk


On Tuesday, 6 June 2017 13:46:58 UTC+1, venturestre...@gmail.com wrote:
>
> On a complete tangent, are you calling a stored procedure there? I thought 
> the database/sql package didn't support MySQL stored procedures yet? 
>

Haven't encountered a serious issue, as yet. Obviously output parameters, 
and probably return values aren't supported.

Selects appear to work fine. With simple single row insert statements 
sql.Result's LastInsertId() only returns 0, though sql.Result's 
RowsAffected() does return 1.

Ren

-- 
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] letsencrypt, localhost and autocert

2017-06-06 Thread Sankar
Hi

I saw the tweet https://twitter.com/mholt6/status/848704744474292224 and 
decided to try out the code

log.Fatal(http.Serve(autocert.NewListener("mydomain.com 
"), handler)) 

but when I try to visit: https://localhost:443, I get an error on the 
server console as: server name component count invalid

Is there any detailed documentation on how to get letsencrypt working with 
golang ?

I am using go 1.8.3

Google gave me https://github.com/golang/go/issues/17053 , but I am not 
able to understand if the letsencrypt support is fully landed or not. Can 
anyone point me to docs and best practices for testing at localhost and 
deploying at production, with https and letsencrypt ? 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] can't build golang.org/x/benchmarks package using gccgo

2017-06-06 Thread Ian Lance Taylor
On Tue, Jun 6, 2017 at 3:46 AM, Joost Shao  wrote:
>
> i know that gccgo vendor not support.

To the best of my knowledge, gccgo does support vendoring.  It was
fixed by https://golang.org/cl/39590 which was committed to GCC in SVN
revision 246864 which is included in the GCC 7 release.

Which version of the go tool are you using?  The one that comes with
gccgo, or the one that comes with the gc toolchain?  The go tool that
comes with the gc toolchain version 1.8.x does not support vendoring
with gccgo.  The patch to the gc toolchain is
https://golang.org/cl/40432, and will be in the upcoming Go 1.9
release.

Ian

> hi, Dave, but even gopath also not supported ?
>
> and what's  the road map?
>
> 在 2017年6月6日星期二 UTC+8下午6:38:32,Dave Cheney写道:
>>
>> I'd say gccgo does not support vendoring.
>>
>>
>> On Tue, 6 Jun 2017, 20:35 Joost Shao  wrote:
>>>
>>>
>>>
>>> 在 2017年6月6日星期二 UTC+8下午6:35:23,Joost Shao写道:



 在 2017年6月6日星期二 UTC+8下午6:34:02,Joost Shao写道:
>
> thank you first, i have been stuck by gccgo-7.x for gopath and govendor
> many days.
>
> gopath is ok, like below.
>
> ubuntu@ubuntu-zesty:~/go/src/github.com/valyala$ tree
> .
> └── fasttemplate
> ├── example_test.go
> ├── LICENSE
> ├── README.md
> ├── template.go
> ├── template_test.go
> ├── template_timing_test.go
> ├── unsafe_gae.go
> ├── unsafe.go
> └── vendor
> └── github.com
> └── valyala
> └── bytebufferpool
> ├── bytebuffer_example_test.go
> ├── bytebuffer.go
> ├── bytebuffer_test.go
> ├── bytebuffer_timing_test.go
> ├── doc.go
> ├── LICENSE
> ├── pool.go
> ├── pool_test.go
> └── README.md
>
> 5 directories, 17 files
>
>
>
> ubuntu@ubuntu-zesty:~$ go env
> GOARCH="amd64"
> GOBIN=""
> GOEXE=""
> GOHOSTARCH="amd64"
> GOHOSTOS="linux"
> GOOS="linux"
> GOPATH="/home/ubuntu/go"
> GORACE=""
> GOROOT="/usr/lib/go-1.7"
> GOTOOLDIR="/usr/lib/go-1.7/pkg/tool/linux_amd64"
> CC="gcc"
> GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0
> -fdebug-prefix-map=/tmp/go-build060029979=/tmp/go-build
> -gno-record-gcc-switches"
> CXX="g++"
> CGO_ENABLED="1"
>
>
> content of main.go
> ubuntu@ubuntu-zesty:~$ cat server.go
> package main
>
> import (
> "net/http"
> "github.com/labstack/echo"
> )
>
> func main() {
> e := echo.New()
> e.GET("/", func(c echo.Context) error {
> return c.String(http.StatusOK, "Hello, World!")
> })
> e.Logger.Fatal(e.Start(":1323"))
> }
>
> by gc compile , the result is OK.
> ubuntu@ubuntu-zesty:~$ go build -x -compiler gc server.go
> WORK=/tmp/go-build058937444
> mkdir -p $WORK/command-line-arguments/_obj/
> mkdir -p $WORK/command-line-arguments/_obj/exe/
> cd /home/ubuntu
> /usr/lib/go-1.7/pkg/tool/linux_amd64/compile -o
> $WORK/command-line-arguments.a -trimpath $WORK -p main -complete -buildid
> 10569227a53a83251f5b0ba912d076c91ac34779 -D _/home/ubuntu -I $WORK -I
> ./go/pkg/linux_amd64 -pack ./server.go
> cd .
> /usr/lib/go-1.7/pkg/tool/linux_amd64/link -o
> $WORK/command-line-arguments/_obj/exe/a.out -L $WORK -L
> /home/ubuntu/go/pkg/linux_amd64 -extld=gcc -buildmode=exe
> -buildid=10569227a53a83251f5b0ba912d076c91ac34779
> $WORK/command-line-arguments.a
> mv $WORK/command-line-arguments/_obj/exe/a.out server
>
> but by gccgo-7.0
> ubuntu@ubuntu-zesty:~$ go build -x -compiler gccgo server.go
> WORK=/tmp/go-build118667055
> mkdir -p $WORK/github.com/mattn/go-isatty/_obj/
> mkdir -p $WORK/github.com/mattn/
> cd /home/ubuntu/go/src/github.com/mattn/go-isatty
> /usr/bin/gccgo -I $WORK -c -g -m64
> -fgo-pkgpath=github.com/mattn/go-isatty
> -fgo-relative-import-path=_/home/ubuntu/go/src/github.com/mattn/go-isatty 
> -o
> $WORK/github.com/mattn/go-isatty/_obj/_go_.o ./doc.go ./isatty_linux.go
> ./isatty_others.go
> mkdir -p $WORK/github.com/mattn/go-colorable/_obj/
> cd /home/ubuntu/go/src/github.com/mattn/go-colorable
> /usr/bin/gccgo -I $WORK -c -g -m64
> -fgo-pkgpath=github.com/mattn/go-colorable
> -fgo-relative-import-path=_/home/ubuntu/go/src/github.com/mattn/go-colorable
> -o $WORK/github.com/mattn/go-colorable/_obj/_go_.o ./colorable_others.go
> ./noncolorable.go
> ar rc $WORK/github.com/mattn/libgo-colorable.a
> $WORK/github.com/mattn/go-colorable/_obj/_go_.o
> mkdir -p
> $WORK/github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool/_obj/
> mkdir -p
> 

[go-nuts] Re: Golang, SQL and ORM avoidance techniques

2017-06-06 Thread venturestreamtemporary
On a complete tangent, are you calling a stored procedure there? I thought 
the database/sql package didn't support MySQL stored procedures yet? 

On Monday, June 5, 2017 at 5:43:33 PM UTC+1, Ren Thraysk wrote:
>
>
> Wrote something similar recently.
>
> One difference is that I moved the rows.Scan call into the passed in 
> function.
>
>
> type Scannable interface {
>   Scan(...interface{}) error
> }
>
> func scanIntoUser(u *store.User) func(s Scannable) error {
>  return func(s Scannable) error {
>  return s.Scan(, , , )
>  }
> }
>
> func (s *userStore) UserByName(name string) (*store.User, error) {
>  u := {}
>  err := ExpectOneRow(s.db, scanIntoUser(u), "CALL spUserByName(?)", name)
>  if err != nil {
>  return nil, err
>  }
>  return u, nil
> }
>
>
>  Idea being gives an opportunity to do some mapping by scanning into local 
> variables and then assign them into the object, for instance dealing with 
> NULLs. Scan into a sql.Null* variable, and modify whatever struct as see 
> appropriate.
>
> Ren
>
>
>
>
> On Friday, 2 June 2017 13:55:12 UTC+1, brylant wrote:
>>
>>
>> I've been trying hard (well.. as much as I can considering my lack of 
>> in-depth go knowledge or - to be perfectly honest - lack of in-depth 
>> knowledge of anything) to find suitable go+sql technique that would not 
>> require a lot of code repetition, not use reflection and not use ORMs of 
>> any sort... Could somebody please tell me if there's anything particularly 
>> wrong with the following:
>>
>>
>> type ScannerFunc func() []interface{}
>>
>> func (db *DB) ScanSome(stmt string, sf ScannerFunc, params ...interface{}) 
>> error {
>>  rows, err := db.Query(stmt, params...)
>>  if err != nil {
>>  return err
>>  }
>>  defer rows.Close()
>>  for rows.Next() {
>>  err = rows.Scan(sf()...)
>>  if err != nil {
>>  return err
>>  }
>>  }
>>  if err = rows.Err(); err != nil {
>>  return err
>>  }
>>  return nil
>> }
>>
>> Having the above I could then implement the following for each of my 
>> 'models' (User being an example below). This could easily be 'go 
>> generate'-d for each model
>>
>>
>> type User struct {
>> UserID  int64
>> Namestring
>> Roleint
>> // (...)
>> }
>>
>> func ScanUsersFunc(users *[]*User) ScannerFunc {
>> return ScannerFunc(func() []interface{}) {
>> u := User{}
>> *users = append(*users, )
>> var r []interface{} = []interface{}{, , , 
>> (more properties)}
>> return r
>> }
>> }
>>
>>
>> and finally use it like this: 
>>
>>
>> const (
>> sqlUsersByRole = "SELECT user_id,name,role, (more if needed) FROM 
>> user WHERE role=?"
>> sqlAllUsers= "SELECT user_id,name,role FROM user"
>> )
>>
>> func (db *DB) UsersByRole(role int) ([]*User, error) {
>> users := make([]*User, 0)
>> err := db.ScanSome(sqlUsersByRole, ScanUsersFunc(), role)
>> if err != nil {
>> return nil, err
>> }
>> return users, nil
>> }
>>
>> func (db *DB) AllUsers() ([]*User, error) {
>> users := make([]*User, 0)
>> err := db.ScanSome(sqlAllUsers, ScanUsersFunc())
>> if err != nil {
>> return nil, err
>> }
>> return users, nil
>> }
>>
>>
>> Alternatively (to avoid scanning/returning all results) a callback could 
>> be provided to ScanSome and called after each scan.
>>
>> Obviously I could also implement ScanOne for situations where I only 
>> expect one row of results...
>>
>>
>> So - any obvious issues with the above 'technique'...?
>>
>>
>> Thanks,
>>
>> adam
>>
>>
>>
>>

-- 
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] Sharing a gorilla/mux router across packages

2017-06-06 Thread nickcorin


I'm having some issues with implementing a slight MVC design with 
gorilla/mux.

The layout of the modules is as follows:

main.go-- controllers base.controller.go example.controller.go-- 
models base.model.go example.controller.go

All the files in controllers is in the controllers package, same with models 
and 
then the main.go is the main package.

Currently I'm just trying to get the Base Controller to be able to be 
shared with the main package which is working, although it's throwing some 
errors when trying to implement routes. The build is not throwing any 
errors, but the routes are not available. If I implement the Walk function 
in the Gorilla/Mux documentation to print out all the registered routes for 
the mux.Router then it gives me this error:

&{%!!(MISSING)s(*mux.Router=&{ [0xc4200901b0] map[] true false false 
false}) %!!(MISSING)s(http.HandlerFunc=0xc8df0) 
[%!!(MISSING)s(*mux.routeRegexp=&{/ false false true false 0xc420095360 / 
[] []})] %!!(MISSING)s(*mux.routeRegexpGroup=&{ 0xc420016240 []}) 
%!!(MISSING)s(bool=true) %!!(MISSING)s(bool=false) 
%!!(MISSING)s(bool=false) %!!(MISSING)s(bool=false) 
%!!(MISSING)s(mux.BuildVarsFunc=)}

The reasoning for the global var V1Router *mux.Router is firstly to access 
it in the main package and also to create subrouters in the other 
controllers.

I am fairly new to Go, but I'm trying my best to learn the best practices! 
Any help would be greatly appreciated!

Example code below:


base.controllers.go

package controllers
import (
"fmt"
"bytes"
"net/http"
"github.com/gorilla/mux")
var V1Router *mux.Router

func init () {
V1Router = mux.NewRouter()
V1Router.StrictSlash(true)
V1Router.HandleFunc("/", BaseHandler)}
// Base route to access the API Documentation.
func BaseHandler (w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Hello, Gophers!")}

main.go

package main
import (
"net/http"
"log"
"github.com/projectrepo/project/models"
"github.com/projectrepo/project/controllers"
"github.com/gorilla/mux")

func main () {
http.Handle("/v1", controllers.V1Router)
if err := http.ListenAndServe(":8000", nil); err != nil {
log.Fatal("Serving 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] can't build golang.org/x/benchmarks package using gccgo

2017-06-06 Thread Joost Shao
hi, thank you , i really know what you mean, 

cd /home/ubuntu/go/src/github.com/valyala/fasttemplate/vendor/github.com/
valyala/bytebufferpool

yes,  the compile -x included vendor , thank you again


在 2017年6月6日星期二 UTC+8下午7:08:35,Dave Cheney写道:
>
>
>
> On Tuesday, 6 June 2017 20:46:38 UTC+10, Joost Shao wrote:
>>
>>
>> i know that gccgo vendor not support.
>>
>> hi, Dave, but even gopath also not supported ?
>>
>
> I don't know what you mean by gopath support, the example you showed had 
> the library inside the projects' vendor directory.
>  
>
>>
>> and what's  the road map?
>>
>
> I'm sorry I don't know. I recommend raising an issue, 
> https://golang.org/issue/new
>  
>
>>
>> 在 2017年6月6日星期二 UTC+8下午6:38:32,Dave Cheney写道:
>>>
>>> I'd say gccgo does not support vendoring. 
>>>
>>> On Tue, 6 Jun 2017, 20:35 Joost Shao  wrote:
>>>


 在 2017年6月6日星期二 UTC+8下午6:35:23,Joost Shao写道:

>
>
> 在 2017年6月6日星期二 UTC+8下午6:34:02,Joost Shao写道:
>>
>> thank you first, i have been stuck by gccgo-7.x for gopath and 
>> govendor many days.
>>
>> gopath is ok, like below.
>>
>> ubuntu@ubuntu-zesty:~/go/src/github.com/valyala$ tree
>> .
>> └── fasttemplate
>> ├── example_test.go
>> ├── LICENSE
>> ├── README.md
>> ├── template.go
>> ├── template_test.go
>> ├── template_timing_test.go
>> ├── unsafe_gae.go
>> ├── unsafe.go
>> └── vendor
>> └── github.com
>> └── valyala
>> └── bytebufferpool
>> ├── bytebuffer_example_test.go
>> ├── bytebuffer.go
>> ├── bytebuffer_test.go
>> ├── bytebuffer_timing_test.go
>> ├── doc.go
>> ├── LICENSE
>> ├── pool.go
>> ├── pool_test.go
>> └── README.md
>>
>> 5 directories, 17 files
>>
>>
>>
>> ubuntu@ubuntu-zesty:~$ go env
>> GOARCH="amd64"
>> GOBIN=""
>> GOEXE=""
>> GOHOSTARCH="amd64"
>> GOHOSTOS="linux"
>> GOOS="linux"
>> GOPATH="/home/ubuntu/go"
>> GORACE=""
>> GOROOT="/usr/lib/go-1.7"
>> GOTOOLDIR="/usr/lib/go-1.7/pkg/tool/linux_amd64"
>> CC="gcc"
>> GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 
>> -fdebug-prefix-map=/tmp/go-build060029979=/tmp/go-build 
>> -gno-record-gcc-switches"
>> CXX="g++"
>> CGO_ENABLED="1"
>>
>>
>> content of main.go
>> ubuntu@ubuntu-zesty:~$ cat server.go
>> package main
>>
>> import (
>> "net/http"
>> "github.com/labstack/echo"
>> )
>>
>> func main() {
>> e := echo.New()
>> e.GET("/", func(c echo.Context) error {
>> return c.String(http.StatusOK, "Hello, World!")
>> })
>> e.Logger.Fatal(e.Start(":1323"))
>> }
>>
>> by gc compile , the result is OK.
>> ubuntu@ubuntu-zesty:~$ go build -x -compiler gc server.go
>> WORK=/tmp/go-build058937444
>> mkdir -p $WORK/command-line-arguments/_obj/
>> mkdir -p $WORK/command-line-arguments/_obj/exe/
>> cd /home/ubuntu
>> /usr/lib/go-1.7/pkg/tool/linux_amd64/compile -o 
>> $WORK/command-line-arguments.a -trimpath $WORK -p main -complete 
>> -buildid 
>> 10569227a53a83251f5b0ba912d076c91ac34779 -D _/home/ubuntu -I $WORK -I 
>> ./go/pkg/linux_amd64 -pack ./server.go
>> cd .
>> /usr/lib/go-1.7/pkg/tool/linux_amd64/link -o 
>> $WORK/command-line-arguments/_obj/exe/a.out -L $WORK -L 
>> /home/ubuntu/go/pkg/linux_amd64 -extld=gcc -buildmode=exe 
>> -buildid=10569227a53a83251f5b0ba912d076c91ac34779 
>> $WORK/command-line-arguments.a
>> mv $WORK/command-line-arguments/_obj/exe/a.out server
>>
>> but by gccgo-7.0
>> ubuntu@ubuntu-zesty:~$ go build -x -compiler gccgo server.go
>> WORK=/tmp/go-build118667055
>> mkdir -p $WORK/github.com/mattn/go-isatty/_obj/
>> mkdir -p $WORK/github.com/mattn/
>> cd /home/ubuntu/go/src/github.com/mattn/go-isatty
>> /usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=
>> github.com/mattn/go-isatty 
>> -fgo-relative-import-path=_/home/ubuntu/go/src/
>> github.com/mattn/go-isatty -o $WORK/
>> github.com/mattn/go-isatty/_obj/_go_.o ./doc.go ./isatty_linux.go 
>> ./isatty_others.go
>> mkdir -p $WORK/github.com/mattn/go-colorable/_obj/
>> cd /home/ubuntu/go/src/github.com/mattn/go-colorable
>> /usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=
>> github.com/mattn/go-colorable 
>> -fgo-relative-import-path=_/home/ubuntu/go/src/
>> github.com/mattn/go-colorable -o $WORK/
>> github.com/mattn/go-colorable/_obj/_go_.o ./colorable_others.go 
>> ./noncolorable.go
>> ar rc $WORK/github.com/mattn/libgo-colorable.a $WORK/
>> github.com/mattn/go-colorable/_obj/_go_.o
>> mkdir -p $WORK/
>> 

Re: [go-nuts] can't build golang.org/x/benchmarks package using gccgo

2017-06-06 Thread Dave Cheney


On Tuesday, 6 June 2017 20:46:38 UTC+10, Joost Shao wrote:
>
>
> i know that gccgo vendor not support.
>
> hi, Dave, but even gopath also not supported ?
>

I don't know what you mean by gopath support, the example you showed had 
the library inside the projects' vendor directory.
 

>
> and what's  the road map?
>

I'm sorry I don't know. I recommend raising an issue, 
https://golang.org/issue/new
 

>
> 在 2017年6月6日星期二 UTC+8下午6:38:32,Dave Cheney写道:
>>
>> I'd say gccgo does not support vendoring. 
>>
>> On Tue, 6 Jun 2017, 20:35 Joost Shao  wrote:
>>
>>>
>>>
>>> 在 2017年6月6日星期二 UTC+8下午6:35:23,Joost Shao写道:
>>>


 在 2017年6月6日星期二 UTC+8下午6:34:02,Joost Shao写道:
>
> thank you first, i have been stuck by gccgo-7.x for gopath and 
> govendor many days.
>
> gopath is ok, like below.
>
> ubuntu@ubuntu-zesty:~/go/src/github.com/valyala$ tree
> .
> └── fasttemplate
> ├── example_test.go
> ├── LICENSE
> ├── README.md
> ├── template.go
> ├── template_test.go
> ├── template_timing_test.go
> ├── unsafe_gae.go
> ├── unsafe.go
> └── vendor
> └── github.com
> └── valyala
> └── bytebufferpool
> ├── bytebuffer_example_test.go
> ├── bytebuffer.go
> ├── bytebuffer_test.go
> ├── bytebuffer_timing_test.go
> ├── doc.go
> ├── LICENSE
> ├── pool.go
> ├── pool_test.go
> └── README.md
>
> 5 directories, 17 files
>
>
>
> ubuntu@ubuntu-zesty:~$ go env
> GOARCH="amd64"
> GOBIN=""
> GOEXE=""
> GOHOSTARCH="amd64"
> GOHOSTOS="linux"
> GOOS="linux"
> GOPATH="/home/ubuntu/go"
> GORACE=""
> GOROOT="/usr/lib/go-1.7"
> GOTOOLDIR="/usr/lib/go-1.7/pkg/tool/linux_amd64"
> CC="gcc"
> GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 
> -fdebug-prefix-map=/tmp/go-build060029979=/tmp/go-build 
> -gno-record-gcc-switches"
> CXX="g++"
> CGO_ENABLED="1"
>
>
> content of main.go
> ubuntu@ubuntu-zesty:~$ cat server.go
> package main
>
> import (
> "net/http"
> "github.com/labstack/echo"
> )
>
> func main() {
> e := echo.New()
> e.GET("/", func(c echo.Context) error {
> return c.String(http.StatusOK, "Hello, World!")
> })
> e.Logger.Fatal(e.Start(":1323"))
> }
>
> by gc compile , the result is OK.
> ubuntu@ubuntu-zesty:~$ go build -x -compiler gc server.go
> WORK=/tmp/go-build058937444
> mkdir -p $WORK/command-line-arguments/_obj/
> mkdir -p $WORK/command-line-arguments/_obj/exe/
> cd /home/ubuntu
> /usr/lib/go-1.7/pkg/tool/linux_amd64/compile -o 
> $WORK/command-line-arguments.a -trimpath $WORK -p main -complete -buildid 
> 10569227a53a83251f5b0ba912d076c91ac34779 -D _/home/ubuntu -I $WORK -I 
> ./go/pkg/linux_amd64 -pack ./server.go
> cd .
> /usr/lib/go-1.7/pkg/tool/linux_amd64/link -o 
> $WORK/command-line-arguments/_obj/exe/a.out -L $WORK -L 
> /home/ubuntu/go/pkg/linux_amd64 -extld=gcc -buildmode=exe 
> -buildid=10569227a53a83251f5b0ba912d076c91ac34779 
> $WORK/command-line-arguments.a
> mv $WORK/command-line-arguments/_obj/exe/a.out server
>
> but by gccgo-7.0
> ubuntu@ubuntu-zesty:~$ go build -x -compiler gccgo server.go
> WORK=/tmp/go-build118667055
> mkdir -p $WORK/github.com/mattn/go-isatty/_obj/
> mkdir -p $WORK/github.com/mattn/
> cd /home/ubuntu/go/src/github.com/mattn/go-isatty
> /usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=
> github.com/mattn/go-isatty 
> -fgo-relative-import-path=_/home/ubuntu/go/src/
> github.com/mattn/go-isatty -o $WORK/
> github.com/mattn/go-isatty/_obj/_go_.o ./doc.go ./isatty_linux.go 
> ./isatty_others.go
> mkdir -p $WORK/github.com/mattn/go-colorable/_obj/
> cd /home/ubuntu/go/src/github.com/mattn/go-colorable
> /usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=
> github.com/mattn/go-colorable 
> -fgo-relative-import-path=_/home/ubuntu/go/src/
> github.com/mattn/go-colorable -o $WORK/
> github.com/mattn/go-colorable/_obj/_go_.o ./colorable_others.go 
> ./noncolorable.go
> ar rc $WORK/github.com/mattn/libgo-colorable.a $WORK/
> github.com/mattn/go-colorable/_obj/_go_.o
> mkdir -p $WORK/
> github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool/_obj/
> mkdir -p $WORK/
> github.com/valyala/fasttemplate/vendor/github.com/valyala/
> cd /home/ubuntu/go/src/
> github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool
> /usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=
> github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool 

Re: [go-nuts] can't build golang.org/x/benchmarks package using gccgo

2017-06-06 Thread Joost Shao
which is OK

WORK=/tmp/go-buildxxx
mkdir -p $WORK/github.com/BurntSushi/toml/_obj/
mkdir -p $WORK/github.com/BurntSushi/
cd /home/ubuntu/go/src/github.com/BurntSushi/toml
/usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=github.com/BurntSushi/toml 
-fgo-relative-import-path=_/home/ubuntu/go/src/github.com/BurntSushi/toml 
-o $WORK/github.com/BurntSushi/toml/_obj/_go_.o ./decode.go 
./decode_meta.go ./doc.go ./encode.go ./encoding_types.go ./lex.go 
./parse.go ./type_check.go ./type_fields.go
ar rc $WORK/github.com/BurntSushi/libtoml.a 
$WORK/github.com/BurntSushi/toml/_obj/_go_.o
mkdir -p $WORK/command-line-arguments/_obj/
mkdir -p $WORK/command-line-arguments/_obj/exe/
cd /home/ubuntu/go/src/github.com/BurntSushi/toml/cmd/tomlv
/usr/bin/gccgo -I $WORK -I /home/ubuntu/go/pkg/gccgo_linux_amd64 -c -g -m64 
-fgo-relative-import-path=_/home/ubuntu/go/src/github.com/BurntSushi/toml/cmd/tomlv
 
-o $WORK/command-line-arguments/_obj/_go_.o ./main.go
ar rc $WORK/libcommand-line-arguments.a 
$WORK/command-line-arguments/_obj/_go_.o
cd .
/usr/bin/gccgo -o $WORK/command-line-arguments/_obj/exe/a.out 
$WORK/command-line-arguments/_obj/_go_.o -Wl,-( -m64 -Wl,--whole-archive 
$WORK/github.com/BurntSushi/libtoml.a -Wl,--no-whole-archive -Wl,-)
mv $WORK/command-line-arguments/_obj/exe/a.out main



在 2017年6月6日星期二 UTC+8下午6:46:38,Joost Shao写道:
>
>
> i know that gccgo vendor not support.
>
> hi, Dave, but even gopath also not supported ?
>
> and what's  the road map?
>
> 在 2017年6月6日星期二 UTC+8下午6:38:32,Dave Cheney写道:
>>
>> I'd say gccgo does not support vendoring. 
>>
>> On Tue, 6 Jun 2017, 20:35 Joost Shao  wrote:
>>
>>>
>>>
>>> 在 2017年6月6日星期二 UTC+8下午6:35:23,Joost Shao写道:
>>>


 在 2017年6月6日星期二 UTC+8下午6:34:02,Joost Shao写道:
>
> thank you first, i have been stuck by gccgo-7.x for gopath and 
> govendor many days.
>
> gopath is ok, like below.
>
> ubuntu@ubuntu-zesty:~/go/src/github.com/valyala$ tree
> .
> └── fasttemplate
> ├── example_test.go
> ├── LICENSE
> ├── README.md
> ├── template.go
> ├── template_test.go
> ├── template_timing_test.go
> ├── unsafe_gae.go
> ├── unsafe.go
> └── vendor
> └── github.com
> └── valyala
> └── bytebufferpool
> ├── bytebuffer_example_test.go
> ├── bytebuffer.go
> ├── bytebuffer_test.go
> ├── bytebuffer_timing_test.go
> ├── doc.go
> ├── LICENSE
> ├── pool.go
> ├── pool_test.go
> └── README.md
>
> 5 directories, 17 files
>
>
>
> ubuntu@ubuntu-zesty:~$ go env
> GOARCH="amd64"
> GOBIN=""
> GOEXE=""
> GOHOSTARCH="amd64"
> GOHOSTOS="linux"
> GOOS="linux"
> GOPATH="/home/ubuntu/go"
> GORACE=""
> GOROOT="/usr/lib/go-1.7"
> GOTOOLDIR="/usr/lib/go-1.7/pkg/tool/linux_amd64"
> CC="gcc"
> GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 
> -fdebug-prefix-map=/tmp/go-build060029979=/tmp/go-build 
> -gno-record-gcc-switches"
> CXX="g++"
> CGO_ENABLED="1"
>
>
> content of main.go
> ubuntu@ubuntu-zesty:~$ cat server.go
> package main
>
> import (
> "net/http"
> "github.com/labstack/echo"
> )
>
> func main() {
> e := echo.New()
> e.GET("/", func(c echo.Context) error {
> return c.String(http.StatusOK, "Hello, World!")
> })
> e.Logger.Fatal(e.Start(":1323"))
> }
>
> by gc compile , the result is OK.
> ubuntu@ubuntu-zesty:~$ go build -x -compiler gc server.go
> WORK=/tmp/go-build058937444
> mkdir -p $WORK/command-line-arguments/_obj/
> mkdir -p $WORK/command-line-arguments/_obj/exe/
> cd /home/ubuntu
> /usr/lib/go-1.7/pkg/tool/linux_amd64/compile -o 
> $WORK/command-line-arguments.a -trimpath $WORK -p main -complete -buildid 
> 10569227a53a83251f5b0ba912d076c91ac34779 -D _/home/ubuntu -I $WORK -I 
> ./go/pkg/linux_amd64 -pack ./server.go
> cd .
> /usr/lib/go-1.7/pkg/tool/linux_amd64/link -o 
> $WORK/command-line-arguments/_obj/exe/a.out -L $WORK -L 
> /home/ubuntu/go/pkg/linux_amd64 -extld=gcc -buildmode=exe 
> -buildid=10569227a53a83251f5b0ba912d076c91ac34779 
> $WORK/command-line-arguments.a
> mv $WORK/command-line-arguments/_obj/exe/a.out server
>
> but by gccgo-7.0
> ubuntu@ubuntu-zesty:~$ go build -x -compiler gccgo server.go
> WORK=/tmp/go-build118667055
> mkdir -p $WORK/github.com/mattn/go-isatty/_obj/
> mkdir -p $WORK/github.com/mattn/
> cd /home/ubuntu/go/src/github.com/mattn/go-isatty
> /usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=
> github.com/mattn/go-isatty 
> -fgo-relative-import-path=_/home/ubuntu/go/src/
> 

Re: [go-nuts] can't build golang.org/x/benchmarks package using gccgo

2017-06-06 Thread Joost Shao

i know that gccgo vendor not support.

hi, Dave, but even gopath also not supported ?

and what's  the road map?

在 2017年6月6日星期二 UTC+8下午6:38:32,Dave Cheney写道:
>
> I'd say gccgo does not support vendoring. 
>
> On Tue, 6 Jun 2017, 20:35 Joost Shao  
> wrote:
>
>>
>>
>> 在 2017年6月6日星期二 UTC+8下午6:35:23,Joost Shao写道:
>>
>>>
>>>
>>> 在 2017年6月6日星期二 UTC+8下午6:34:02,Joost Shao写道:

 thank you first, i have been stuck by gccgo-7.x for gopath and govendor 
 many days.

 gopath is ok, like below.

 ubuntu@ubuntu-zesty:~/go/src/github.com/valyala$ tree
 .
 └── fasttemplate
 ├── example_test.go
 ├── LICENSE
 ├── README.md
 ├── template.go
 ├── template_test.go
 ├── template_timing_test.go
 ├── unsafe_gae.go
 ├── unsafe.go
 └── vendor
 └── github.com
 └── valyala
 └── bytebufferpool
 ├── bytebuffer_example_test.go
 ├── bytebuffer.go
 ├── bytebuffer_test.go
 ├── bytebuffer_timing_test.go
 ├── doc.go
 ├── LICENSE
 ├── pool.go
 ├── pool_test.go
 └── README.md

 5 directories, 17 files



 ubuntu@ubuntu-zesty:~$ go env
 GOARCH="amd64"
 GOBIN=""
 GOEXE=""
 GOHOSTARCH="amd64"
 GOHOSTOS="linux"
 GOOS="linux"
 GOPATH="/home/ubuntu/go"
 GORACE=""
 GOROOT="/usr/lib/go-1.7"
 GOTOOLDIR="/usr/lib/go-1.7/pkg/tool/linux_amd64"
 CC="gcc"
 GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 
 -fdebug-prefix-map=/tmp/go-build060029979=/tmp/go-build 
 -gno-record-gcc-switches"
 CXX="g++"
 CGO_ENABLED="1"


 content of main.go
 ubuntu@ubuntu-zesty:~$ cat server.go
 package main

 import (
 "net/http"
 "github.com/labstack/echo"
 )

 func main() {
 e := echo.New()
 e.GET("/", func(c echo.Context) error {
 return c.String(http.StatusOK, "Hello, World!")
 })
 e.Logger.Fatal(e.Start(":1323"))
 }

 by gc compile , the result is OK.
 ubuntu@ubuntu-zesty:~$ go build -x -compiler gc server.go
 WORK=/tmp/go-build058937444
 mkdir -p $WORK/command-line-arguments/_obj/
 mkdir -p $WORK/command-line-arguments/_obj/exe/
 cd /home/ubuntu
 /usr/lib/go-1.7/pkg/tool/linux_amd64/compile -o 
 $WORK/command-line-arguments.a -trimpath $WORK -p main -complete -buildid 
 10569227a53a83251f5b0ba912d076c91ac34779 -D _/home/ubuntu -I $WORK -I 
 ./go/pkg/linux_amd64 -pack ./server.go
 cd .
 /usr/lib/go-1.7/pkg/tool/linux_amd64/link -o 
 $WORK/command-line-arguments/_obj/exe/a.out -L $WORK -L 
 /home/ubuntu/go/pkg/linux_amd64 -extld=gcc -buildmode=exe 
 -buildid=10569227a53a83251f5b0ba912d076c91ac34779 
 $WORK/command-line-arguments.a
 mv $WORK/command-line-arguments/_obj/exe/a.out server

 but by gccgo-7.0
 ubuntu@ubuntu-zesty:~$ go build -x -compiler gccgo server.go
 WORK=/tmp/go-build118667055
 mkdir -p $WORK/github.com/mattn/go-isatty/_obj/
 mkdir -p $WORK/github.com/mattn/
 cd /home/ubuntu/go/src/github.com/mattn/go-isatty
 /usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=
 github.com/mattn/go-isatty 
 -fgo-relative-import-path=_/home/ubuntu/go/src/
 github.com/mattn/go-isatty -o $WORK/
 github.com/mattn/go-isatty/_obj/_go_.o ./doc.go ./isatty_linux.go 
 ./isatty_others.go
 mkdir -p $WORK/github.com/mattn/go-colorable/_obj/
 cd /home/ubuntu/go/src/github.com/mattn/go-colorable
 /usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=
 github.com/mattn/go-colorable 
 -fgo-relative-import-path=_/home/ubuntu/go/src/
 github.com/mattn/go-colorable -o $WORK/
 github.com/mattn/go-colorable/_obj/_go_.o ./colorable_others.go 
 ./noncolorable.go
 ar rc $WORK/github.com/mattn/libgo-colorable.a $WORK/
 github.com/mattn/go-colorable/_obj/_go_.o
 mkdir -p $WORK/
 github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool/_obj/
 mkdir -p $WORK/
 github.com/valyala/fasttemplate/vendor/github.com/valyala/
 cd /home/ubuntu/go/src/
 github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool
 /usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=
 github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool 
 -fgo-relative-import-path=_/home/ubuntu/go/src/
 github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool 
 -o $WORK/
 github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool/_obj/_go_.o
  
 ./bytebuffer.go ./doc.go ./pool.go
 cd /home/ubuntu/go/src/github.com/mattn/go-isatty
 ar rc $WORK/github.com/mattn/libgo-isatty.a $WORK/
 

Re: [go-nuts] can't build golang.org/x/benchmarks package using gccgo

2017-06-06 Thread Dave Cheney
I'd say gccgo does not support vendoring.

On Tue, 6 Jun 2017, 20:35 Joost Shao  wrote:

>
>
> 在 2017年6月6日星期二 UTC+8下午6:35:23,Joost Shao写道:
>
>>
>>
>> 在 2017年6月6日星期二 UTC+8下午6:34:02,Joost Shao写道:
>>>
>>> thank you first, i have been stuck by gccgo-7.x for gopath and govendor
>>> many days.
>>>
>>> gopath is ok, like below.
>>>
>>> ubuntu@ubuntu-zesty:~/go/src/github.com/valyala$ tree
>>> .
>>> └── fasttemplate
>>> ├── example_test.go
>>> ├── LICENSE
>>> ├── README.md
>>> ├── template.go
>>> ├── template_test.go
>>> ├── template_timing_test.go
>>> ├── unsafe_gae.go
>>> ├── unsafe.go
>>> └── vendor
>>> └── github.com
>>> └── valyala
>>> └── bytebufferpool
>>> ├── bytebuffer_example_test.go
>>> ├── bytebuffer.go
>>> ├── bytebuffer_test.go
>>> ├── bytebuffer_timing_test.go
>>> ├── doc.go
>>> ├── LICENSE
>>> ├── pool.go
>>> ├── pool_test.go
>>> └── README.md
>>>
>>> 5 directories, 17 files
>>>
>>>
>>>
>>> ubuntu@ubuntu-zesty:~$ go env
>>> GOARCH="amd64"
>>> GOBIN=""
>>> GOEXE=""
>>> GOHOSTARCH="amd64"
>>> GOHOSTOS="linux"
>>> GOOS="linux"
>>> GOPATH="/home/ubuntu/go"
>>> GORACE=""
>>> GOROOT="/usr/lib/go-1.7"
>>> GOTOOLDIR="/usr/lib/go-1.7/pkg/tool/linux_amd64"
>>> CC="gcc"
>>> GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0
>>> -fdebug-prefix-map=/tmp/go-build060029979=/tmp/go-build
>>> -gno-record-gcc-switches"
>>> CXX="g++"
>>> CGO_ENABLED="1"
>>>
>>>
>>> content of main.go
>>> ubuntu@ubuntu-zesty:~$ cat server.go
>>> package main
>>>
>>> import (
>>> "net/http"
>>> "github.com/labstack/echo"
>>> )
>>>
>>> func main() {
>>> e := echo.New()
>>> e.GET("/", func(c echo.Context) error {
>>> return c.String(http.StatusOK, "Hello, World!")
>>> })
>>> e.Logger.Fatal(e.Start(":1323"))
>>> }
>>>
>>> by gc compile , the result is OK.
>>> ubuntu@ubuntu-zesty:~$ go build -x -compiler gc server.go
>>> WORK=/tmp/go-build058937444
>>> mkdir -p $WORK/command-line-arguments/_obj/
>>> mkdir -p $WORK/command-line-arguments/_obj/exe/
>>> cd /home/ubuntu
>>> /usr/lib/go-1.7/pkg/tool/linux_amd64/compile -o
>>> $WORK/command-line-arguments.a -trimpath $WORK -p main -complete -buildid
>>> 10569227a53a83251f5b0ba912d076c91ac34779 -D _/home/ubuntu -I $WORK -I
>>> ./go/pkg/linux_amd64 -pack ./server.go
>>> cd .
>>> /usr/lib/go-1.7/pkg/tool/linux_amd64/link -o
>>> $WORK/command-line-arguments/_obj/exe/a.out -L $WORK -L
>>> /home/ubuntu/go/pkg/linux_amd64 -extld=gcc -buildmode=exe
>>> -buildid=10569227a53a83251f5b0ba912d076c91ac34779
>>> $WORK/command-line-arguments.a
>>> mv $WORK/command-line-arguments/_obj/exe/a.out server
>>>
>>> but by gccgo-7.0
>>> ubuntu@ubuntu-zesty:~$ go build -x -compiler gccgo server.go
>>> WORK=/tmp/go-build118667055
>>> mkdir -p $WORK/github.com/mattn/go-isatty/_obj/
>>> mkdir -p $WORK/github.com/mattn/
>>> cd /home/ubuntu/go/src/github.com/mattn/go-isatty
>>> /usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=
>>> github.com/mattn/go-isatty
>>> -fgo-relative-import-path=_/home/ubuntu/go/src/
>>> github.com/mattn/go-isatty -o $WORK/
>>> github.com/mattn/go-isatty/_obj/_go_.o ./doc.go ./isatty_linux.go
>>> ./isatty_others.go
>>> mkdir -p $WORK/github.com/mattn/go-colorable/_obj/
>>> cd /home/ubuntu/go/src/github.com/mattn/go-colorable
>>> /usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=
>>> github.com/mattn/go-colorable
>>> -fgo-relative-import-path=_/home/ubuntu/go/src/
>>> github.com/mattn/go-colorable -o $WORK/
>>> github.com/mattn/go-colorable/_obj/_go_.o ./colorable_others.go
>>> ./noncolorable.go
>>> ar rc $WORK/github.com/mattn/libgo-colorable.a $WORK/
>>> github.com/mattn/go-colorable/_obj/_go_.o
>>> mkdir -p $WORK/
>>> github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool/_obj/
>>> mkdir -p $WORK/
>>> github.com/valyala/fasttemplate/vendor/github.com/valyala/
>>> cd /home/ubuntu/go/src/
>>> github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool
>>> /usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=
>>> github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool
>>> -fgo-relative-import-path=_/home/ubuntu/go/src/
>>> github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool
>>> -o $WORK/
>>> github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool/_obj/_go_.o
>>> ./bytebuffer.go ./doc.go ./pool.go
>>> cd /home/ubuntu/go/src/github.com/mattn/go-isatty
>>> ar rc $WORK/github.com/mattn/libgo-isatty.a $WORK/
>>> github.com/mattn/go-isatty/_obj/_go_.o
>>> mkdir -p $WORK/github.com/labstack/gommon/color/_obj/
>>> mkdir -p $WORK/github.com/labstack/gommon/
>>> cd /home/ubuntu/go/src/github.com/labstack/gommon/color
>>> /usr/bin/gccgo -I $WORK -I /home/ubuntu/go/pkg/gccgo_linux_amd64 -c -g
>>> -m64 -fgo-pkgpath=github.com/labstack/gommon/color
>>> 

Re: [go-nuts] can't build golang.org/x/benchmarks package using gccgo

2017-06-06 Thread Joost Shao


在 2017年6月6日星期二 UTC+8下午6:35:23,Joost Shao写道:
>
>
>
> 在 2017年6月6日星期二 UTC+8下午6:34:02,Joost Shao写道:
>>
>> thank you first, i have been stuck by gccgo-7.x for gopath and govendor 
>> many days.
>>
>> gopath is ok, like below.
>>
>> ubuntu@ubuntu-zesty:~/go/src/github.com/valyala$ tree
>> .
>> └── fasttemplate
>> ├── example_test.go
>> ├── LICENSE
>> ├── README.md
>> ├── template.go
>> ├── template_test.go
>> ├── template_timing_test.go
>> ├── unsafe_gae.go
>> ├── unsafe.go
>> └── vendor
>> └── github.com
>> └── valyala
>> └── bytebufferpool
>> ├── bytebuffer_example_test.go
>> ├── bytebuffer.go
>> ├── bytebuffer_test.go
>> ├── bytebuffer_timing_test.go
>> ├── doc.go
>> ├── LICENSE
>> ├── pool.go
>> ├── pool_test.go
>> └── README.md
>>
>> 5 directories, 17 files
>>
>>
>>
>> ubuntu@ubuntu-zesty:~$ go env
>> GOARCH="amd64"
>> GOBIN=""
>> GOEXE=""
>> GOHOSTARCH="amd64"
>> GOHOSTOS="linux"
>> GOOS="linux"
>> GOPATH="/home/ubuntu/go"
>> GORACE=""
>> GOROOT="/usr/lib/go-1.7"
>> GOTOOLDIR="/usr/lib/go-1.7/pkg/tool/linux_amd64"
>> CC="gcc"
>> GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 
>> -fdebug-prefix-map=/tmp/go-build060029979=/tmp/go-build 
>> -gno-record-gcc-switches"
>> CXX="g++"
>> CGO_ENABLED="1"
>>
>>
>> content of main.go
>> ubuntu@ubuntu-zesty:~$ cat server.go
>> package main
>>
>> import (
>> "net/http"
>> "github.com/labstack/echo"
>> )
>>
>> func main() {
>> e := echo.New()
>> e.GET("/", func(c echo.Context) error {
>> return c.String(http.StatusOK, "Hello, World!")
>> })
>> e.Logger.Fatal(e.Start(":1323"))
>> }
>>
>> by gc compile , the result is OK.
>> ubuntu@ubuntu-zesty:~$ go build -x -compiler gc server.go
>> WORK=/tmp/go-build058937444
>> mkdir -p $WORK/command-line-arguments/_obj/
>> mkdir -p $WORK/command-line-arguments/_obj/exe/
>> cd /home/ubuntu
>> /usr/lib/go-1.7/pkg/tool/linux_amd64/compile -o 
>> $WORK/command-line-arguments.a -trimpath $WORK -p main -complete -buildid 
>> 10569227a53a83251f5b0ba912d076c91ac34779 -D _/home/ubuntu -I $WORK -I 
>> ./go/pkg/linux_amd64 -pack ./server.go
>> cd .
>> /usr/lib/go-1.7/pkg/tool/linux_amd64/link -o 
>> $WORK/command-line-arguments/_obj/exe/a.out -L $WORK -L 
>> /home/ubuntu/go/pkg/linux_amd64 -extld=gcc -buildmode=exe 
>> -buildid=10569227a53a83251f5b0ba912d076c91ac34779 
>> $WORK/command-line-arguments.a
>> mv $WORK/command-line-arguments/_obj/exe/a.out server
>>
>> but by gccgo-7.0
>> ubuntu@ubuntu-zesty:~$ go build -x -compiler gccgo server.go
>> WORK=/tmp/go-build118667055
>> mkdir -p $WORK/github.com/mattn/go-isatty/_obj/
>> mkdir -p $WORK/github.com/mattn/
>> cd /home/ubuntu/go/src/github.com/mattn/go-isatty
>> /usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=
>> github.com/mattn/go-isatty 
>> -fgo-relative-import-path=_/home/ubuntu/go/src/github.com/mattn/go-isatty 
>> -o $WORK/github.com/mattn/go-isatty/_obj/_go_.o ./doc.go 
>> ./isatty_linux.go ./isatty_others.go
>> mkdir -p $WORK/github.com/mattn/go-colorable/_obj/
>> cd /home/ubuntu/go/src/github.com/mattn/go-colorable
>> /usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=
>> github.com/mattn/go-colorable 
>> -fgo-relative-import-path=_/home/ubuntu/go/src/
>> github.com/mattn/go-colorable -o $WORK/
>> github.com/mattn/go-colorable/_obj/_go_.o ./colorable_others.go 
>> ./noncolorable.go
>> ar rc $WORK/github.com/mattn/libgo-colorable.a $WORK/
>> github.com/mattn/go-colorable/_obj/_go_.o
>> mkdir -p $WORK/
>> github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool/_obj/
>> mkdir -p $WORK/github.com/valyala/fasttemplate/vendor/github.com/valyala/
>> cd /home/ubuntu/go/src/
>> github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool
>> /usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=
>> github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool 
>> -fgo-relative-import-path=_/home/ubuntu/go/src/
>> github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool 
>> -o $WORK/
>> github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool/_obj/_go_.o
>>  
>> ./bytebuffer.go ./doc.go ./pool.go
>> cd /home/ubuntu/go/src/github.com/mattn/go-isatty
>> ar rc $WORK/github.com/mattn/libgo-isatty.a $WORK/
>> github.com/mattn/go-isatty/_obj/_go_.o
>> mkdir -p $WORK/github.com/labstack/gommon/color/_obj/
>> mkdir -p $WORK/github.com/labstack/gommon/
>> cd /home/ubuntu/go/src/github.com/labstack/gommon/color
>> /usr/bin/gccgo -I $WORK -I /home/ubuntu/go/pkg/gccgo_linux_amd64 -c -g 
>> -m64 -fgo-pkgpath=github.com/labstack/gommon/color 
>> -fgo-relative-import-path=_/home/ubuntu/go/src/
>> github.com/labstack/gommon/color -o $WORK/
>> github.com/labstack/gommon/color/_obj/_go_.o ./color.go
>> cd /home/ubuntu/go/src/
>> 

Re: [go-nuts] can't build golang.org/x/benchmarks package using gccgo

2017-06-06 Thread Joost Shao


在 2017年6月6日星期二 UTC+8下午6:34:02,Joost Shao写道:
>
> thank you first, i have been stuck by gccgo-7.x for gopath and govendor 
> many days.
>
> gopath is ok, like below.
>
> ubuntu@ubuntu-zesty:~/go/src/github.com/valyala$ tree
> .
> └── fasttemplate
> ├── example_test.go
> ├── LICENSE
> ├── README.md
> ├── template.go
> ├── template_test.go
> ├── template_timing_test.go
> ├── unsafe_gae.go
> ├── unsafe.go
> └── vendor
> └── github.com
> └── valyala
> └── bytebufferpool
> ├── bytebuffer_example_test.go
> ├── bytebuffer.go
> ├── bytebuffer_test.go
> ├── bytebuffer_timing_test.go
> ├── doc.go
> ├── LICENSE
> ├── pool.go
> ├── pool_test.go
> └── README.md
>
> 5 directories, 17 files
>
>
>
> ubuntu@ubuntu-zesty:~$ go env
> GOARCH="amd64"
> GOBIN=""
> GOEXE=""
> GOHOSTARCH="amd64"
> GOHOSTOS="linux"
> GOOS="linux"
> GOPATH="/home/ubuntu/go"
> GORACE=""
> GOROOT="/usr/lib/go-1.7"
> GOTOOLDIR="/usr/lib/go-1.7/pkg/tool/linux_amd64"
> CC="gcc"
> GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 
> -fdebug-prefix-map=/tmp/go-build060029979=/tmp/go-build 
> -gno-record-gcc-switches"
> CXX="g++"
> CGO_ENABLED="1"
>
>
> content of main.go
> ubuntu@ubuntu-zesty:~$ cat server.go
> package main
>
> import (
> "net/http"
> "github.com/labstack/echo"
> )
>
> func main() {
> e := echo.New()
> e.GET("/", func(c echo.Context) error {
> return c.String(http.StatusOK, "Hello, World!")
> })
> e.Logger.Fatal(e.Start(":1323"))
> }
>
> by gc compile , the result is OK.
> ubuntu@ubuntu-zesty:~$ go build -x -compiler gc server.go
> WORK=/tmp/go-build058937444
> mkdir -p $WORK/command-line-arguments/_obj/
> mkdir -p $WORK/command-line-arguments/_obj/exe/
> cd /home/ubuntu
> /usr/lib/go-1.7/pkg/tool/linux_amd64/compile -o 
> $WORK/command-line-arguments.a -trimpath $WORK -p main -complete -buildid 
> 10569227a53a83251f5b0ba912d076c91ac34779 -D _/home/ubuntu -I $WORK -I 
> ./go/pkg/linux_amd64 -pack ./server.go
> cd .
> /usr/lib/go-1.7/pkg/tool/linux_amd64/link -o 
> $WORK/command-line-arguments/_obj/exe/a.out -L $WORK -L 
> /home/ubuntu/go/pkg/linux_amd64 -extld=gcc -buildmode=exe 
> -buildid=10569227a53a83251f5b0ba912d076c91ac34779 
> $WORK/command-line-arguments.a
> mv $WORK/command-line-arguments/_obj/exe/a.out server
>
> but by gccgo-7.0
> ubuntu@ubuntu-zesty:~$ go build -x -compiler gccgo server.go
> WORK=/tmp/go-build118667055
> mkdir -p $WORK/github.com/mattn/go-isatty/_obj/
> mkdir -p $WORK/github.com/mattn/
> cd /home/ubuntu/go/src/github.com/mattn/go-isatty
> /usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=github.com/mattn/go-isatty 
> -fgo-relative-import-path=_/home/ubuntu/go/src/github.com/mattn/go-isatty 
> -o $WORK/github.com/mattn/go-isatty/_obj/_go_.o ./doc.go 
> ./isatty_linux.go ./isatty_others.go
> mkdir -p $WORK/github.com/mattn/go-colorable/_obj/
> cd /home/ubuntu/go/src/github.com/mattn/go-colorable
> /usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=
> github.com/mattn/go-colorable 
> -fgo-relative-import-path=_/home/ubuntu/go/src/
> github.com/mattn/go-colorable -o $WORK/
> github.com/mattn/go-colorable/_obj/_go_.o ./colorable_others.go 
> ./noncolorable.go
> ar rc $WORK/github.com/mattn/libgo-colorable.a $WORK/
> github.com/mattn/go-colorable/_obj/_go_.o
> mkdir -p $WORK/
> github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool/_obj/
> mkdir -p $WORK/github.com/valyala/fasttemplate/vendor/github.com/valyala/
> cd /home/ubuntu/go/src/
> github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool
> /usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=
> github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool 
> -fgo-relative-import-path=_/home/ubuntu/go/src/
> github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool 
> -o $WORK/
> github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool/_obj/_go_.o
>  
> ./bytebuffer.go ./doc.go ./pool.go
> cd /home/ubuntu/go/src/github.com/mattn/go-isatty
> ar rc $WORK/github.com/mattn/libgo-isatty.a $WORK/
> github.com/mattn/go-isatty/_obj/_go_.o
> mkdir -p $WORK/github.com/labstack/gommon/color/_obj/
> mkdir -p $WORK/github.com/labstack/gommon/
> cd /home/ubuntu/go/src/github.com/labstack/gommon/color
> /usr/bin/gccgo -I $WORK -I /home/ubuntu/go/pkg/gccgo_linux_amd64 -c -g 
> -m64 -fgo-pkgpath=github.com/labstack/gommon/color 
> -fgo-relative-import-path=_/home/ubuntu/go/src/
> github.com/labstack/gommon/color -o $WORK/
> github.com/labstack/gommon/color/_obj/_go_.o ./color.go
> cd /home/ubuntu/go/src/
> github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool
> ar rc $WORK/
> github.com/valyala/fasttemplate/vendor/github.com/valyala/libbytebufferpool.a 
> $WORK/
> 

Re: [go-nuts] can't build golang.org/x/benchmarks package using gccgo

2017-06-06 Thread Joost Shao
thank you first, i have been stuck by gccgo-7.x for gopath and govendor 
many days.

gopath is ok, like below.

ubuntu@ubuntu-zesty:~/go/src/github.com/valyala$ tree
.
└── fasttemplate
├── example_test.go
├── LICENSE
├── README.md
├── template.go
├── template_test.go
├── template_timing_test.go
├── unsafe_gae.go
├── unsafe.go
└── vendor
└── github.com
└── valyala
└── bytebufferpool
├── bytebuffer_example_test.go
├── bytebuffer.go
├── bytebuffer_test.go
├── bytebuffer_timing_test.go
├── doc.go
├── LICENSE
├── pool.go
├── pool_test.go
└── README.md

5 directories, 17 files



ubuntu@ubuntu-zesty:~$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/ubuntu/go"
GORACE=""
GOROOT="/usr/lib/go-1.7"
GOTOOLDIR="/usr/lib/go-1.7/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 
-fdebug-prefix-map=/tmp/go-build060029979=/tmp/go-build 
-gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"


content of main.go
ubuntu@ubuntu-zesty:~$ cat server.go
package main

import (
"net/http"
"github.com/labstack/echo"
)

func main() {
e := echo.New()
e.GET("/", func(c echo.Context) error {
return c.String(http.StatusOK, "Hello, World!")
})
e.Logger.Fatal(e.Start(":1323"))
}

by gc compile , the result is OK.
ubuntu@ubuntu-zesty:~$ go build -x -compiler gc server.go
WORK=/tmp/go-build058937444
mkdir -p $WORK/command-line-arguments/_obj/
mkdir -p $WORK/command-line-arguments/_obj/exe/
cd /home/ubuntu
/usr/lib/go-1.7/pkg/tool/linux_amd64/compile -o 
$WORK/command-line-arguments.a -trimpath $WORK -p main -complete -buildid 
10569227a53a83251f5b0ba912d076c91ac34779 -D _/home/ubuntu -I $WORK -I 
./go/pkg/linux_amd64 -pack ./server.go
cd .
/usr/lib/go-1.7/pkg/tool/linux_amd64/link -o 
$WORK/command-line-arguments/_obj/exe/a.out -L $WORK -L 
/home/ubuntu/go/pkg/linux_amd64 -extld=gcc -buildmode=exe 
-buildid=10569227a53a83251f5b0ba912d076c91ac34779 
$WORK/command-line-arguments.a
mv $WORK/command-line-arguments/_obj/exe/a.out server

but by gccgo-7.0
ubuntu@ubuntu-zesty:~$ go build -x -compiler gccgo server.go
WORK=/tmp/go-build118667055
mkdir -p $WORK/github.com/mattn/go-isatty/_obj/
mkdir -p $WORK/github.com/mattn/
cd /home/ubuntu/go/src/github.com/mattn/go-isatty
/usr/bin/gccgo -I $WORK -c -g -m64 -fgo-pkgpath=github.com/mattn/go-isatty 
-fgo-relative-import-path=_/home/ubuntu/go/src/github.com/mattn/go-isatty 
-o $WORK/github.com/mattn/go-isatty/_obj/_go_.o ./doc.go ./isatty_linux.go 
./isatty_others.go
mkdir -p $WORK/github.com/mattn/go-colorable/_obj/
cd /home/ubuntu/go/src/github.com/mattn/go-colorable
/usr/bin/gccgo -I $WORK -c -g -m64 
-fgo-pkgpath=github.com/mattn/go-colorable 
-fgo-relative-import-path=_/home/ubuntu/go/src/github.com/mattn/go-colorable 
-o $WORK/github.com/mattn/go-colorable/_obj/_go_.o ./colorable_others.go 
./noncolorable.go
ar rc $WORK/github.com/mattn/libgo-colorable.a 
$WORK/github.com/mattn/go-colorable/_obj/_go_.o
mkdir -p 
$WORK/github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool/_obj/
mkdir -p $WORK/github.com/valyala/fasttemplate/vendor/github.com/valyala/
cd 
/home/ubuntu/go/src/github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool
/usr/bin/gccgo -I $WORK -c -g -m64 
-fgo-pkgpath=github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool
 
-fgo-relative-import-path=_/home/ubuntu/go/src/github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool
 
-o 
$WORK/github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool/_obj/_go_.o
 
./bytebuffer.go ./doc.go ./pool.go
cd /home/ubuntu/go/src/github.com/mattn/go-isatty
ar rc $WORK/github.com/mattn/libgo-isatty.a 
$WORK/github.com/mattn/go-isatty/_obj/_go_.o
mkdir -p $WORK/github.com/labstack/gommon/color/_obj/
mkdir -p $WORK/github.com/labstack/gommon/
cd /home/ubuntu/go/src/github.com/labstack/gommon/color
/usr/bin/gccgo -I $WORK -I /home/ubuntu/go/pkg/gccgo_linux_amd64 -c -g -m64 
-fgo-pkgpath=github.com/labstack/gommon/color 
-fgo-relative-import-path=_/home/ubuntu/go/src/github.com/labstack/gommon/color 
-o $WORK/github.com/labstack/gommon/color/_obj/_go_.o ./color.go
cd 
/home/ubuntu/go/src/github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool
ar rc 
$WORK/github.com/valyala/fasttemplate/vendor/github.com/valyala/libbytebufferpool.a
 
$WORK/github.com/valyala/fasttemplate/vendor/github.com/valyala/bytebufferpool/_obj/_go_.o
mkdir -p $WORK/github.com/valyala/fasttemplate/_obj/
mkdir -p $WORK/github.com/valyala/
cd /home/ubuntu/go/src/github.com/valyala/fasttemplate
/usr/bin/gccgo -I $WORK -I /home/ubuntu/go/pkg/gccgo_linux_amd64 -c -g -m64 
-fgo-pkgpath=github.com/valyala/fasttemplate 

[go-nuts] add note to google groups golang-nuts introduction text

2017-06-06 Thread fgergo
If I understand correctly
https://groups.google.com/forum/#!forum/golang-nuts is usually the top
search result for "go mailing list" or similar queries.
I suggest adding something like this near the 4 listed rules:
"Please note: this is a google groups interface to a mailing list, you
can't delete the emails (>5k) your post generates."

On Fri, Jun 2, 2017 at 2:55 PM, Rudi  wrote:
> Well,  I deleted my original post before Ian replied because I anticipated
> his answer 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] can't build golang.org/x/benchmarks package using gccgo

2017-06-06 Thread Dave Cheney
Does the missing package exist in your gopath?

On Tue, 6 Jun 2017, 17:24 Joost Shao  wrote:

> what about now ? i used gccgo-7 to compile framework echo, but failed .
>
> error is blow:
>
> ubuntu@ubuntu-zesty:~$ gccgo-7 -v
> Using built-in specs.
> COLLECT_GCC=gccgo-7
> COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
> OFFLOAD_TARGET_NAMES=nvptx-none
> OFFLOAD_TARGET_DEFAULT=1
> Target: x86_64-linux-gnu
> Configured with: ../src/configure -v --with-pkgversion='Ubuntu
> 7-20170407-0ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs
> --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
> --with-gcc-major-version-only --program-suffix=-7
> --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
> --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
> --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
> --enable-libstdcxx-debug --enable-libstdcxx-time=yes
> --with-default-libstdcxx-abi=new --enable-gnu-unique-object
> --disable-vtable-verify --enable-libmpx --enable-plugin
> --enable-default-pie --with-system-zlib --with-target-system-zlib
> --enable-objc-gc=auto --enable-multiarch --disable-werror
> --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
> --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
> --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu
> --host=x86_64-linux-gnu --target=x86_64-linux-gnu
> Thread model: posix
> gcc version 7.0.1 20170407 (experimental) [trunk revision 246759] (Ubuntu
> 7-20170407-0ubuntu2)
>
>
> ubuntu@ubuntu-zesty:~$ go build -compiler gccgo  server.go
> # github.com/valyala/fasttemplate
> go/src/github.com/valyala/fasttemplate/template.go:12:35: error: import
> file ‘github.com/valyala/bytebufferpool’ not found
>   "github.com/valyala/bytebufferpool"
>^
> go/src/github.com/valyala/fasttemplate/template.go:99:34: error: expected
> package
>  var byteBufferPool bytebufferpool.Pool
>   ^
> go/src/github.com/valyala/fasttemplate/template.go:124:31: error:
> expected package
>   byteBufferPool bytebufferpool.Pool
>^
> go/src/github.com/valyala/fasttemplate/template.go:140:2: error: return
> with value in function with no return type
>   return t
>   ^
> go/src/github.com/valyala/fasttemplate/template.go:152:3: error: return
> with value in function with no return type
>return nil, err
>^
> go/src/github.com/valyala/fasttemplate/template.go:154:2: error: return
> with value in function with no return type
>   return , nil
>   ^
> go/src/github.com/valyala/fasttemplate/template.go:267:2: error: not
> enough arguments to return
>   return t.ExecuteFunc(w, func(w io.Writer, tag string) (int, error) {
> return stdTagFunc(w, tag, m) })
>   ^
>
>
> it seems not support import third party package.
>
> anyone can help me ?
>
> 在 2015年12月11日星期五 UTC+8上午10:48:49,Zhongwei Yao写道:
>>
>> OK, I'll give a try to newer gccgo.
>>
>
>> On 11 December 2015 at 10:28, Dave Cheney  wrote:
>>
>>> I think gccgo is well supported and benefits from the mature gcc
>>> toolchain, ubuntu is just shipping an out of date version.
>>>
>>> On Friday, 11 December 2015 13:17:12 UTC+11, Zhongwei Yao wrote:

 Hi, Dave, Thanks for your information! I've built and run several
 programs by gc without any problem on arm64. Programs include benchmark
 cases like build, garbage, http, json in golang.org/x/benchmark
 package. The gc is built from recently master branch. And we also have
 tried go 1.5.1 to run docker on arm64, it also works. If you want more
 details, please tell me.

 What I want to do is comparing the performance between gccgo and gc.
 BTW, I'm new to golang. And I don't know why the community is supporting
 both gccgo and gc. Gccgo seems support a lot of architecture, but it is not
 well supported in cases like my problem.

 On 10 December 2015 at 20:17, Dave Cheney  wrote:

> I believe gccgo 4.9 only implements the go 1.3 spec. sync.Pool was
> added in 1.4.
>
> You will have to compile a newer gccgo to.compile that program.
>
> BTW, did you know what go 1.5 and later support arm64 natively?
>
> Thanks
>
> 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...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



 --
 Best regards,
 Zhongwei

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