[go-nuts] Re: Go policy does not fully support previous release

2019-10-01 Thread Christoph Berger
A question based on genuine interest: Which factors make it hard for you to 
upgrade to the latest Go release?


On Monday, September 30, 2019 at 9:49:39 PM UTC+2, Liam wrote:
>
> I was startled to learn that regressions found in the previous release 
> (currently 1.12.x) will not be fixed in that release. Regressions are only 
> fixed in the most recent release.
>
> If you wait until 1.12.5 to upgrade a deployment from 1.11.x, and then 
> discover a regression on the day 1.13 comes out, tough luck. Either upgrade 
> again to 1.13 or resort to a custom build.
>
> I filed a proposal to change this:
> https://github.com/golang/go/issues/34622
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/9964ea39-6978-4fb0-83bb-bd7cbd509ee7%40googlegroups.com.


Re: [go-nuts] Call of a Go-function inside C-code

2019-10-01 Thread Ian Lance Taylor
On Tue, Oct 1, 2019 at 7:36 PM  wrote:
>
> what is wrong with the following simple code, which yields "undefined 
> reference for F" ?
>
>
> file f.go:
>
> package main
> // #include "f.h"
> // void f (int a) { F(a) }
> import "C"
>
> func F(a int) { println(a) }
> func main() { C.f(7) }
>
>
> file f.h:
>
> extern void F (int a);
>
> //export F

Putting "//export F" in f.h isn't going to do anything.  A "//export"
comment has to appear just before the Go function that you want to
export.

Note that as explained at https://golang.org/cmd/cgo, "Using //export
in a file places a restriction on the preamble: since it is copied
into two different C output files, it must not contain any
definitions, only declarations."  In the above f.go, "void f (int a) {
F(a) }" is a definition.  So you can't use that in conjunction with an
"//export" comment.

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcWODXnv267tcTsPSrf0JYs4OzNsrhd0Nr5n5a%2By-TaSyA%40mail.gmail.com.


[go-nuts] Re: causal profiling in Go

2019-10-01 Thread Gerald Stan
Hi, interesting work. @Ingo is that the only way run casual profiling in go?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/32dc27f9-7990-4137-ada4-dfaf7833ec03%40googlegroups.com.


[go-nuts] Call of a Go-function inside C-code

2019-10-01 Thread dr . ch . maurer
Dear community,

what is wrong with the following simple code, which yields "undefined 
reference for F" ?


file f.go:

package main
// #include "f.h"
// void f (int a) { F(a) }
import "C"

func F(a int) { println(a) }
func main() { C.f(7) }


file f.h:

extern void F (int a);

//export F


Thanks in advance for any help,
Christian

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e31defe4-fde3-47c5-b052-8979939257a2%40googlegroups.com.


[go-nuts] Re: A question about performance when traverse the array with row-wise and column-wise

2019-10-01 Thread lgodio2
Are your test results different  when rowSize = colSize> 1000 say ??



On Sunday, September 29, 2019 at 10:18:15 AM UTC-4, zct wrote:
>
> The test code is below:
> package main
>
> import (
> "testing"
> )
>
> const rowSize = 100
> const colSize = 100
>
> var array [rowSize][colSize]int
>
> func BenchmarkRow(b *testing.B) {
> b.ResetTimer()
> for i := 0; i < b.N; i++ {
> sum := 0
> for r := 0; r < rowSize; r++ {
> for c := 0; c < colSize; c++ {
> sum += array[r][c]
> }
> }
> }
> }
>
> func BenchmarkColumn(b *testing.B) {
> b.ResetTimer()
> for i := 0; i < b.N; i++ {
> sum := 0
> for c := 0; c < colSize; c++ {
> for r := 0; r < rowSize; r++ {
> sum += array[r][c]
> }
> }
> }
> }
>
>
> As we known, there is a cpu cache in computer, so the row-wise should 
> perform better than the column-wise. But the test result is :
>
> go test -bench=. -count=5
> goos: darwin
> goarch: amd64
> BenchmarkRow-430  42926367 ns/op
> BenchmarkRow-430  50048505 ns/op
> BenchmarkRow-432  38466153 ns/op
> BenchmarkRow-428  40887279 ns/op
> BenchmarkRow-430  36325967 ns/op
> BenchmarkColumn-4 34  30991838 ns/op
> BenchmarkColumn-4 36  30965998 ns/op
> BenchmarkColumn-4 39  31575142 ns/op
> BenchmarkColumn-4 33  35048352 ns/op
> BenchmarkColumn-4 38  32584167 ns/op
> PASS
>
> It show that the column-wise traverse is quicker than the row-wise. I test 
> it in my macbook and ubuntu server, the result is the same
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/7424c9d6-51d0-4f59-81a4-b0635fc40530%40googlegroups.com.


Re: [go-nuts] HTTP timeout per handler

2019-10-01 Thread Nitin Sanghi
Yes you can do by check size of file or whatever payload you are receiving.
You can make run time decision for time

On Tue, Oct 1, 2019, 10:57 AM Santiago Corredoira 
wrote:

> Hi Nitin, but how about making the timeout longer thant the default? For
> example having a general write timeout of 1 minute but allowing a certain
> user to download a large file for 30 min.
>
> El mar., 1 oct. 2019 a las 6:31, Nitin Sanghi ()
> escribió:
>
>> Santiago, you can use context to cancel the request after the certain
>> time you like.
>>
>>  ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)
>>  defer cancel()  // releases
>>
>>
>> On Mon, Sep 30, 2019, 8:54 PM Santiago Corredoira 
>> wrote:
>>
>>> Using the http package, timeouts are defined per server. Is there any
>>> way of changing it for a specific handler? Imagine a long download from a
>>> loged user or a websocket but also be protected against clients that don't
>>> close connections and fload the 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.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/golang-nuts/1622fd96-3758-4066-9428-220b5887ddd5%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAJpEBv_3zp0Emp0GKDSwWPJb4m9P_5GKoqA%3DOA2Ht93QngrOcQ%40mail.gmail.com.


Re: [go-nuts] HTTP timeout per handler

2019-10-01 Thread Nitin Sanghi
Santiago, you can use context to cancel the request after the certain time
you like.

ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)
defer cancel()  // releases


On Mon, Sep 30, 2019, 8:54 PM Santiago Corredoira 
wrote:

> Using the http package, timeouts are defined per server. Is there any way
> of changing it for a specific handler? Imagine a long download from a loged
> user or a websocket but also be protected against clients that don't close
> connections and fload the 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/1622fd96-3758-4066-9428-220b5887ddd5%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAJpEBv_fahuSEXhwq0jd%3D%2BeD_1P-r3iv6JGcjTDrH3ATqZBwVw%40mail.gmail.com.


Re: [go-nuts] Golang library for - ORM & Schema Migration

2019-10-01 Thread Sam Whited
On Mon, Sep 30, 2019, at 21:05, bram wrote:
> Thank you all. For schema migration i am looking for similar tool
> like flyway.

I'm not sure if it's like flyway, but I use a library that I wrote,
code.soquee.net/migration [1]. The idea is that it gives you the tools
you need to write a migration command instead of being a separate
migration tool, this way your application can handle its own migrations
(this makes it really easy to distribute your application to customers
if you have an on-premis version that their ops people will need to run
migrations on). It is designed to run migrations from a folder or
embedded filesystem (eg. using statik [2] or pkgzip [3]). Currently it
is compatible with Diesel and supports PostgreSQL, but it could likely
be made to support whatever you're using easily enough.

—Sam

[1]: https://godoc.org/code.soquee.net/migration
[2]: https://godoc.org/github.com/rakyll/statik
[3]: https://godoc.org/code.soquee.net/pkgzip

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ee783450-0354-41d7-8d7f-67c0498cf9c1%40www.fastmail.com.


Re: [go-nuts] go 1.13 won't compile

2019-10-01 Thread rob

I figured out the source of these reported difference in behaviors.

My win10 system does not have a go.mod file, but my LinuxMint system 
does.  When I deleted that (and unset GO111MODULE) I was able to compile 
on LinuxMint.


So the differences depend on whether there is already a go.mod file in 
my ~/go/src directory.


Thanks for all the help guys.

--rob

On 9/30/19 1:27 PM, Michael Ellis wrote:

Robert,
It's probably worth a careful look at 
https://github.com/golang/go/wiki/Modules#recent-changes and 
https://golang.org/doc/go1.13#modules as well as Marcin's suggestion 
to run go env. When I do the latter, I get


GO111MODULE=""
GOPRIVATE=""
(among many other variables but those are probably the important 
ones). Those settings are working for me for projects that have 
modules and for projects that don't.


One possibility is that some pieces of version 1.12 are still hanging 
around.  As you  probably know the recommended approach to upgrading 
requires removing the older version before installing the new.  See 
https://golang.org/doc/install#uninstall


Cheers,
Mike

/“I want you to act as if the house was on fire. Because it is.” — 
Greta Thunberg/



On Mon, Sep 30, 2019 at 12:21 PM Marcin Romaszewicz > wrote:


Could you post the output of "go env" run on linux mint? Maybe
there's a clue in there.


On Mon, Sep 30, 2019 at 9:14 AM Robert Solomon mailto:drrob...@gmail.com>> wrote:

Then my question becomes, what's different about linuxmint
19.2 to require me to set GO111MODULE=no

On Mon, Sep 30, 2019, 11:06 AM Everton Marques
mailto:everton.marq...@gmail.com>>
wrote:

Your code from playground compiled fine for me on Debian
Linux.
Tested with Go 1.13 and 1.13.1.

Just had to include the missing func:

|
func GetUserGroupStr(f os.FileInfo)(string,string){
return"foo","bar"
}
|



Em segunda-feira, 30 de setembro de 2019 11:34:52 UTC-3,
Robert Solomon escreveu:

Your experience matches mine when compiled on windows 10.

But linuxmint experience is as I described.   Another
responder asked me if it works when I set GO111MODULE=no.

It does work when I do that.   I find it interesting
that the linux behavior seems to be different

On Mon, Sep 30, 2019, 9:17 AM Michael Ellis
 wrote:

FWIW, I copied your code from Go Playground into
~/go/src/dsrt/dsrt.go on my OS X machine.  I
replaced an undefined function at line 375 (see
below) with direct assignments for usernameStr and
groupNameStr. It compiled (with go build) and ran
without reporting an error under go 1.13.

// usernameStr, groupnameStr := GetUserGroupStr(f)
// util function in platform specific code, only
for linux and windows.  Not needed anymore.
Probably won't compile for foreign computer.
  // GetUserGroupStr() is undefined, so hardcode a
couple of nonsense strings to test compilation.
usernameStr := "foo"
groupnameStr := "bar"



On Saturday, September 28, 2019 at 2:55:51 PM
UTC-4, rob wrote:

I guess I was not clear enough.  My
apologies.  dsrt is my own code.  I remember
an earlier posting on this list recommended
'go install' instead of 'go build'

~/go/src/dsrt/dsrt.go, util_linux.go,
util_windows.go

And I have written other small programs in go
that I use for myself. I put it in
https://play.golang.org/p/U7FgzpqCh-B

It compiles and runs fine on go 1.12.x under
linux, and fine on go 1.13 under windows 10. 
I have not yet installed go1.13.1 on my
windows 10 box.

I remember a promise that anything that
compiles under go 1.0.0 will not be broken.
Not being able to compile using go 1.13 that
works fine using go 1.12.x, broke my code.

I'm not a professional programmer.  I don't
know what else to include here to demonstrate
my problem.

Thanks for your response.

--rob solomon



On 9/28/19 11:42 AM, Marcin Romaszewicz wrote:

What was 

[go-nuts] Go modules - Apache Maven BOM equivalent?

2019-10-01 Thread Stevo Slavić
Hello Gophers,

Is anyone aware is it already possible or are there any plans to support in
Go modules something like Apache Maven's BOM POM support for:
- ability to publish release metadata (modules and versions) about a
multi-module project (e.g. like Kubernetes) and then also
- ability to easily enforce that any direct or transitive dependency in a
given project should be overridden / replaced with version from a given
release?

Kind regards,
Stevo Slavic.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAAUywg8R%2BUTsubAZ68xs%3Dn2%3DWKnoVnkNj5Gbz_%3DdG3bJ3wmQdw%40mail.gmail.com.


Re: [go-nuts] Golang library for - ORM & Schema Migration

2019-10-01 Thread Andrew Pillar
I created a simple migration tool called mgrt [1], which operates on pure SQL
scripts that are defined by the user. It has support for MySQL, SQLite and
PostgreSQL. Give it a try if you're looking for a simple migration tool that
just uses plain SQL under the hood. It's written in Go, so building it won't be
too hard.

[1] - https://github.com/andrewpillar/mgrt

Accidentally replied to the wrong thread on the list with this :/

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/f3abdba2-7e2b-4bdb-9054-b9694eb48445%40www.fastmail.com.


[go-nuts] Re: Can’t get latest package version with modules

2019-10-01 Thread Christophe Meessen
I finally understood. The GOPATH definition is not relevant here. It is the 
presence of the go.mod file that determines if the module mode is in 
application. With go1.13, without go.mod file, the old GOPATH mode is in 
application. 

The go.mod file is create by "go mod init [package name]". When present, a 
"go get" will download and install all dependencies. 

Sorry for the noise. 

Le mardi 1 octobre 2019 08:59:55 UTC+2, Christophe Meessen a écrit :
>
> When GOPATH is defined (~/go), 
>
> go get -u github.com/XXX/go-YYY@latest
>
> doesn’t work. I get the error message:
>
> go: cannot use path@version syntax in GOPATH mode
>
> This is with go1.13.1. 
>
> Does this mean that GOPATH must be undefined to use modules with 1.13.1 ? 
> I thought that with go1.13 modules was used everywhere. 
> The rules are non-intuitive and not explicit. 
>
> Le lundi 30 septembre 2019 11:17:11 UTC+2, Christophe Meessen a écrit :
>>
>> Solved the issue with the command:
>>
>> go get -u github.com/XXX/go-YYY@latest
>>
>> Is there another way  ? 
>>
>> Le lundi 30 septembre 2019 11:01:17 UTC+2, Christophe Meessen a écrit :
>>>
>>> I have a small go program to test a third party package stored on 
>>> github. 
>>> I’m using go1.13.1 with no GOPATH defined. Code is in ~/go/src. 
>>>
>>> When I first tried to compile the program, there was an error in the 
>>> third party package. I submitted a pull request to fix it and the manager 
>>> merged it. 
>>>
>>> The problem I’m facing now is that I can’t get go to use the newest 
>>> version of the package. 
>>>
>>> If I remove the require line in the go.mod file and do a go get, or go 
>>> get -u, or go get -u , I always get the older package although go 
>>> prints the message "go: finding github.com/XXX/go-YYY latest". It’s 
>>> definitely not the latest. 
>>> I’m stuck now and don’t know how to download the really latest version 
>>> of the package. 
>>>
>>> I guess I’m not supposed to manually clean the go cache (~/go/src/mod/
>>> github.com/XXX/go-YYY@...), or am I ? 
>>>
>>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e7fb2f66-c0d7-407a-a6d6-0527d14036ad%40googlegroups.com.


Re: [go-nuts] Re: Can’t get latest package version with modules

2019-10-01 Thread Andrew Pillar
>Thank you all. For schema migration i am looking for similar tool like flyway.

I created a simple migration tool called mgrt [1], which operates on pure SQL
scripts that are defined by the user. It has support for MySQL, SQLite and
PostgreSQL. Give it a try if you're looking for a simple migration tool that
just uses plain SQL under the hood. It's written in Go, so building it won't be
too hard.

[1] - https://github.com/andrewpillar/mgrt

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/51af693e-b999-41eb-8563-d199d7b5647e%40www.fastmail.com.


[go-nuts] Re: Can’t get latest package version with modules

2019-10-01 Thread Christophe Meessen
When GOPATH is defined (~/go), 

go get -u github.com/XXX/go-YYY@latest

doesn’t work. I get the error message:

go: cannot use path@version syntax in GOPATH mode

This is with go1.13.1. 

Does this mean that GOPATH must be undefined to use modules with 1.13.1 ? I 
thought that with go1.13 modules was used everywhere. 
The rules are non-intuitive and not explicit. 

Le lundi 30 septembre 2019 11:17:11 UTC+2, Christophe Meessen a écrit :
>
> Solved the issue with the command:
>
> go get -u github.com/XXX/go-YYY@latest
>
> Is there another way  ? 
>
> Le lundi 30 septembre 2019 11:01:17 UTC+2, Christophe Meessen a écrit :
>>
>> I have a small go program to test a third party package stored on github. 
>> I’m using go1.13.1 with no GOPATH defined. Code is in ~/go/src. 
>>
>> When I first tried to compile the program, there was an error in the 
>> third party package. I submitted a pull request to fix it and the manager 
>> merged it. 
>>
>> The problem I’m facing now is that I can’t get go to use the newest 
>> version of the package. 
>>
>> If I remove the require line in the go.mod file and do a go get, or go 
>> get -u, or go get -u , I always get the older package although go 
>> prints the message "go: finding github.com/XXX/go-YYY latest". It’s 
>> definitely not the latest. 
>> I’m stuck now and don’t know how to download the really latest version of 
>> the package. 
>>
>> I guess I’m not supposed to manually clean the go cache (~/go/src/mod/
>> github.com/XXX/go-YYY@...), or am I ? 
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/c71e539f-3926-4fb0-b3bb-92e3d2c19dff%40googlegroups.com.