[go-nuts] Re: An intresting behaviour about number of allocations in []byte->string conversions

2020-08-14 Thread T L
Sorry, I temporarily switch to Go 1.3. The result is constantly 0 0 1 for Go 1.15 when N > 2. On Saturday, August 15, 2020 at 12:30:32 AM UTC-4, T L wrote: > > > package main > > import "fmt" > import "bytes" > import "testing" > > const N = 0 > var name = bytes.Repeat([]byte{'x'}, N) > var m = ma

[go-nuts] [generics]: Pointer methods in interfaces used as constraints?

2020-08-14 Thread Patrick Smith
https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md#pointer-method-example has this example: // Setter2 is a type constraint that requires that the type // implement a Set method that sets the value from a string, // and also requires that the type be a poin

[go-nuts] An intresting behaviour about number of allocations in []byte->string conversions

2020-08-14 Thread T L
package main import "fmt" import "bytes" import "testing" const N = 0 var name = bytes.Repeat([]byte{'x'}, N) var m = make(map[string]string, 10) var s string func f() { s = m[string(name)] } func g() { key := string(name) s = m[key] } func h() { m[string(name)] = "Golang" }

Re: [go-nuts] Generics: after type lists

2020-08-14 Thread Patrick Smith
On Thu, Aug 13, 2020 at 11:25 PM Patrick Smith wrote: > I tried out a few different implementations, evaluating the polynomial > instead of finding roots, > at https://go2goplay.golang.org/p/g8bPHdg5iMd . As far as I can tell, > there is no sensible way to > do it with an interface that is impleme

[go-nuts] The latest version of package in pkg.go.dev

2020-08-14 Thread Tong Sun
How to force update the latest version of package in pkg.go.dev? My https://github.com/go-easygen/easygen/releases/tag/v5.1.01 has been release for over 10 days, but the https://pkg.go.dev/github.com/go-easygen/easygen?tab=versions is still showing an old version. >From https://proxy.golang.o

Re: [go-nuts] Re: module confusion

2020-08-14 Thread Marvin Renich
* Volker Dobler [200814 14:53]: > On Friday, 14 August 2020 20:39:37 UTC+2, K Richard Pixley wrote: > > Isn't this the default location? I just untarred the distribution... > > No. There is a reason https://golang.org/doc/install#install > states to do tar -C /usr/local -xzf go$VERSION.$OS-$AR

Re: [go-nuts] [ generics ] Concrete example of comparables and generic function types

2020-08-14 Thread Beka Westberg
> Thanks for the example. My pleasure :D Thank you for taking a look! > Nice example! Presumably if you wanted to do actual Porter-Duff though, you'd want some arithmetic rather than just comparison. Thank you! And yeah if you wanted to do something like a color-dodge or other blend modes you'

[go-nuts] basics of understanding golang memory usage

2020-08-14 Thread Mike Spreitzer
I have several basic questions. I examined a couple of golang programs, and got really confused. I started by looking at a kube-proxy from Kubernetes release 1.15 (probably either 1.15.9 or 1.15.12) on Linux 4.15.0 using `/proc/[pid]/statm`. As a reminder, here is what man procfs has to say a

Re: [go-nuts] [ generics ] Concrete example of comparables and generic function types

2020-08-14 Thread roger peppe
Nice example! Presumably if you wanted to do actual Porter-Duff though, you'd want some arithmetic rather than just comparison. One observation: you don't actually need the "comparable" constraint on many of the core entities there (e.g. Rect and Op) because they don't actually use any compare ope

Re: [go-nuts] [ generics ] Concrete example of comparables and generic function types

2020-08-14 Thread Ian Lance Taylor
On Thu, Aug 13, 2020 at 8:37 PM Beka Westberg wrote: > > Hello! I just ran into a problem that is solved really nicely with the new > generics proposal and I thought someone might find it interesting :D > > I was trying to implement a library for doing ascii art programmatically. The > main stru

Re: [go-nuts] How to build an object file for a specific GOOS and GOARCH with external linker?

2020-08-14 Thread Ian Lance Taylor
On Fri, Aug 14, 2020 at 8:29 AM wrote: > > i'm trying to create an object file by using "go build" for GOOS=linux > GOARCH=386. > My current go environment has GOOS=linux GOARCH=amd64. > > i know that go build directly builds and links the files, but i want to link > files using an external link

Re: [go-nuts] Re: module confusion

2020-08-14 Thread 'K Richard Pixley' via golang-nuts
On 8/14/20 11:54, 'Carla Pfaff' via golang-nuts wrote: People and installers usually install Go in /usr/local/go on Unix-like systems. ~/go is the default GOPATH if not set, so ~/go/bin is where binaries installed via "go get" / "go install" land. But the Go distribution itself must not be un

Re: [go-nuts] map without default values

2020-08-14 Thread 'Axel Wagner' via golang-nuts
On Fri, Aug 14, 2020 at 8:52 PM Joe Marty wrote: > >> If I know that a value exists, or am fine using the zero value (again, >> that's the majority of my personal use-cases for maps at least), having to >> use a statement just to discard the extra bool is annoying. >> > > Right, so this brings me

Re: [go-nuts] Re: module confusion

2020-08-14 Thread 'Carla Pfaff' via golang-nuts
People and installers usually install Go in /usr/local/go on Unix-like systems. ~/go is the default GOPATH if not set, so ~/go/bin is where binaries installed via "go get" / "go install" land. But the Go distribution itself must not be under GOPATH. -- You received this message because you ar

Re: [go-nuts] Re: module confusion

2020-08-14 Thread Volker Dobler
On Friday, 14 August 2020 20:39:37 UTC+2, K Richard Pixley wrote: > > Isn't this the default location? I just untarred the distribution... > No. There is a reason https://golang.org/doc/install#install states to do tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz V. -- You received this me

Re: [go-nuts] map without default values

2020-08-14 Thread Joe Marty
> > > If I know that a value exists, or am fine using the zero value (again, > that's the majority of my personal use-cases for maps at least), having to > use a statement just to discard the extra bool is annoying. > Right, so this brings me back to a nice solution to both our use cases, wh

Re: [go-nuts] Go1.15 + SQLite Driver + Windows + Ld.exe results in ld error "unrecognized option --high-entropy-va"

2020-08-14 Thread Sean O'Neil
Never mind, I just noticed the original post answered it. Sorry, read it too quickly. On Thursday, August 13, 2020 at 3:13:51 PM UTC-4 Ian Lance Taylor wrote: > On Thu, Aug 13, 2020 at 12:01 PM Corey Gilmore > wrote: > > > > Setup: > > - Go 1.15 > > - https://github.com/mattn/go-sqlite3 SQL d

Re: [go-nuts] Go1.15 + SQLite Driver + Windows + Ld.exe results in ld error "unrecognized option --high-entropy-va"

2020-08-14 Thread Sean O'Neil
Just upgraded from 1.12 to 1.15 and ran into this as well. What about those of us who can't so easily upgrade the version of MingW we're using? Is there no way to disable that option when building cgo projects from the command-line? If not, does 1.14 use it, or do I have to go back even farther

Re: [go-nuts] Re: module confusion

2020-08-14 Thread 'K Richard Pixley' via golang-nuts
On 8/14/20 11:27, 'Carla Pfaff' via golang-nuts wrote: This has nothing to do with modules. You're still using the old GOPATH mode, because you're not in a directory with a go.mod file. GOPATH defaults to $HOME/go when it's not set (since 1.8), but that's where you chose to put your Go installa

[go-nuts] Re: module confusion

2020-08-14 Thread 'Carla Pfaff' via golang-nuts
This has nothing to do with modules. You're still using the old GOPATH mode, because you're not in a directory with a go.mod file. GOPATH defaults to $HOME/go when it's not set (since 1.8), but that's where you chose to put your Go installation. This is not allowed. Either install Go to a diffe

Re: [go-nuts] module confusion

2020-08-14 Thread 'K Richard Pixley' via golang-nuts
On 8/14/20 11:20, Jan Mercl wrote: [External Email. Be cautious of content] On Fri, Aug 14, 2020 at 8:03 PM 'K Richard Pixley' via golang-nuts wrote: What am I missing? package github.com/mna/pigeon: cannot download, $GOPATH must not be set to $GOROOT. For more details see: 'go help gopath'

Re: [go-nuts] module confusion

2020-08-14 Thread Jan Mercl
On Fri, Aug 14, 2020 at 8:03 PM 'K Richard Pixley' via golang-nuts wrote: > What am I missing? > package github.com/mna/pigeon: cannot download, $GOPATH must not be set to > $GOROOT. For more details see: 'go help gopath' The above is the problem > GOPATH="/homes/kpixley/go" > GOROOT="/homes

[go-nuts] module confusion

2020-08-14 Thread 'K Richard Pixley' via golang-nuts
I'm consistently finding modules confusing. Here's today's confusion.  I /think/ I've eliminated local environment settings but, once done, go get isn't working and I don't understand what needs to be changed.  What am I missing? kpixley@editsb> type go -bash: type: go: not found kpixley@edit

Re: [go-nuts] map without default values

2020-08-14 Thread 'Axel Wagner' via golang-nuts
On Fri, Aug 14, 2020 at 6:17 PM Joe Marty wrote: > Yeah, I can see how the convention of "always testing for failure" is > better than a panic, in that it requires you to handle the possibility of a > failure for things that may commonly fail. In that respect though, I don't > understand why the

[go-nuts] [modules] List available only patch upgrades

2020-08-14 Thread Jérôme LAFORGE
Hello Gophers, I want to list modules available only for available only patch upgrades. The given example here https://github.com/golang/go/wiki/Modules#how-to-upgrade-and-downgrade-dependencies is for direct with minor and patch (I just want patch) I want use this in my CI with https://github

Re: [go-nuts] where is go code generate type info?

2020-08-14 Thread xie cui
i find the reference code in cmd/compile/internal/gc/reflect.go On Friday, August 14, 2020 at 8:52:54 PM UTC+8 Volker Dobler wrote: > On Friday, 14 August 2020 13:00:19 UTC+2, xie cui wrote: >> >> the return instance of reflect.TypeOf(some object) should be generate by >> compiler, the type info

Re: [go-nuts] map without default values

2020-08-14 Thread Joe Marty
Thanks for the insights! Yeah, I can see how the convention of "always testing for failure" is better than a panic, in that it requires you to handle the possibility of a failure for things that may commonly fail. In that respect though, I don't understand why the "comma OK" is optional. Elm,

[go-nuts] Re: Windows 'Access is denied' for os.Remove after exec.Output()

2020-08-14 Thread jake...@gmail.com
> Turns out it takes some time to release the lock on the folder, so we should do some time.Sleep before the os.Remove, so that Windows can release the lock. I do not believe that should be the case under normal Windows operation. Using a Sleep in a case like this is always a hack. Sometimes

[go-nuts] How to build an object file for a specific GOOS and GOARCH with external linker?

2020-08-14 Thread rotusmailbox
i'm trying to create an object file by using "go build" for GOOS=linux GOARCH=386. My current go environment has GOOS=linux GOARCH=amd64. i know that go build directly builds and links the files, but i want to link files using an external linker file, so i need only the object file to be create

Re: [go-nuts] where is go code generate type info?

2020-08-14 Thread Mikael Gustavsson
But those two lines don't do much, the first line reads the type pointer out of the interface, and the function toType is just a nil check: https://golang.org/src/reflect/type.go?s=38892:38923#L2963 I'm guessing xie cui is looking for where the instances of for example structType: https://golan

[go-nuts] Re: Windows 'Access is denied' for os.Remove after exec.Output()

2020-08-14 Thread atakanc...@gmail.com
Hello guys, I have solved the issue. Turns out it takes some time to release the lock on the folder, so we should do some time.Sleep before the os.Remove, so that Windows can release the lock. Thank you both for replying. 14 Ağustos 2020 Cuma tarihinde saat 16:21:17 UTC+3 itibarıyla jake...@

[go-nuts] Re: Windows 'Access is denied' for os.Remove after exec.Output()

2020-08-14 Thread jake...@gmail.com
This works fine for me on Windows 10. What is "my.exe" doing? Do you have third party antivirus software? If so, try turning it off. They are notorious for causing this kind of problem. On Friday, August 14, 2020 at 5:02:36 AM UTC-4 atakanc...@gmail.com wrote: > Hello dear fellow gophers, >

Re: [go-nuts] where is go code generate type info?

2020-08-14 Thread Volker Dobler
On Friday, 14 August 2020 13:00:19 UTC+2, xie cui wrote: > > the return instance of reflect.TypeOf(some object) should be generate by > compiler, the type info which could be in elf files. i want to known where > compiler generate it. > Maybe this is the reason for your confusion. Your assumptio

Re: [go-nuts] where is go code generate type info?

2020-08-14 Thread xie cui
i am reading gc's code. i just need to know. reflect.TypeOf return a interface, the interface ref to a instance or call data. that instance should be generate by compiler. but i can not find where is the compiler code that generate data about type. On Friday, August 14, 2020 at 7:00:19 PM UTC+8

Re: [go-nuts] where is go code generate type info?

2020-08-14 Thread xie cui
the return instance of reflect.TypeOf(some object) should be generate by compiler, the type info which could be in elf files. i want to known where compiler generate it. On Friday, August 14, 2020 at 5:08:30 PM UTC+8 Volker Dobler wrote: > On Friday, 14 August 2020 08:15:03 UTC+2, xie cui wrot

[go-nuts] Re: Windows 'Access is denied' for os.Remove after exec.Output()

2020-08-14 Thread atakanc...@gmail.com
Thank you for your reply. Unfortunately taskkill returns 128 buffer, err := exec.Command("my.exe", myArgs...).Output() // err is nil here, I get desired output _, err := exec.Command("taskkill", "/F", "/im", "my.exe").Output() // err is exit code 128, tried same with /pid, cmd.Process.Pid as we

Re: [go-nuts] [ generics ] Added constraint type inference to the design draft

2020-08-14 Thread roger peppe
On Thu, 13 Aug 2020 at 23:30, Ian Lance Taylor wrote: > On Thu, Aug 13, 2020 at 3:09 PM roger peppe wrote: > > > > I do feel that the "all or nothing" nature of type parameter lists (if > you specify one type parameter, you must explicitly specify all of the > others too, even if they could othe

[go-nuts] Re: Windows 'Access is denied' for os.Remove after exec.Output()

2020-08-14 Thread Tamás Gulácsi
Windows locks the running program's file, you cannot delete it when it's running - use "taskkill /F" to kill it proper. atakanc...@gmail.com a következőt írta (2020. augusztus 14., péntek, 11:02:36 UTC+2): > Hello dear fellow gophers, > > I had a relatively simple yet quite inconvenient issue

Re: [go-nuts] where is go code generate type info?

2020-08-14 Thread Volker Dobler
On Friday, 14 August 2020 08:15:03 UTC+2, xie cui wrote: > > > how can i see the code genrate by compiler, and where is the compiler code > to generate these code(which file, which function). i am just curious. Can you explain what you mean exactly by "code generated by the compiler"? Are you i

[go-nuts] Windows 'Access is denied' for os.Remove after exec.Output()

2020-08-14 Thread Atakan Çolak
Hello dear fellow gophers, I had a relatively simple yet quite inconvenient issue which I felt the need to ask here. In my main() function; os.Remove("my.exe") // err is nil, my.exe is removed works in Windows without any errors, but when I call exec beforehand, I get access is denied error;