Re: [go-nuts] Go present installation

2018-01-29 Thread Ian Lance Taylor
On Mon, Jan 29, 2018 at 12:49 PM, wilson wrote: > > On a Mac with go version 1.9.3 with a GOPATH=$HOME/go with the subdirs src, > pkg, and bin, I ran: > > go get golang.org/x/tools/present > > The source was downloaded and present.a was downloaded into > $GOPATH/pkg/darwin_amd64/golang.org/x/too

Re: [go-nuts] Re: trying to find out if there's already a Go v2 roadmap

2018-01-30 Thread Ian Lance Taylor
On Tue, Jan 30, 2018 at 4:53 AM, evan wrote: > Just to clarify, i meant GUI library for Desktop App > > > On Tuesday, January 30, 2018 at 8:20:15 PM UTC+8, evan wrote: >> >> also, could a Go Team-supported GUI library be in Go's near future? The closest we've got is golang.org/x/exp/shiny. I'm n

Re: [go-nuts] where in gc compiler does converting from syntax.TypeDecl to reflect.Type happen?

2018-01-30 Thread Ian Lance Taylor
On Mon, Jan 29, 2018 at 11:21 PM, Jason E. Aten wrote: > > I wrote some code to convert (go/types) types.Type to reflect.Type, > > but I kept thinking, "this has to be done somewhere already in > the runtime or compiler libraries...", doesn't it? > > [ I know gc doesn't use go/types, but assume I'

Re: [go-nuts] Unit tests - same vs separate package

2018-01-30 Thread Ian Lance Taylor
On Tue, Jan 30, 2018 at 4:45 AM, Stevo Slavić wrote: > > Official docs recommend putting unit tests in same package as package under > test, see: > - https://golang.org/doc/faq#How_do_I_write_a_unit_test > - https://golang.org/pkg/testing/ > > Practical experience (see > https://medium.com/@matrye

Re: [go-nuts] Guarantees about evaluation order but not slice indexing

2018-01-30 Thread Ian Lance Taylor
On Tue, Jan 30, 2018 at 10:20 AM, Dmitriy Cherchenko wrote: > > The second possibility you described is exactly what I’m worried about. But I > have several places where I’m doing something like b.data[b.grow()] = bt and > wouldn’t want to break that up into two lines everywhere. I was wondering

Re: [go-nuts] SIGSEGV with cgo

2018-01-30 Thread Ian Lance Taylor
On Tue, Jan 30, 2018 at 9:13 PM, hǎi sū wrote: > the code is below. > ``` > package main > > import "math/rand" > import "fmt" > > /* > #include > #include > > void t(const short *buf, size_t buf_size) { > printf("in t."); > printf("0: %d ", buf[0]); > printf("buf_size-1: %d\n", buf[buf_size-1])

Re: [go-nuts] Documentation issue on the Getting Started page

2018-02-01 Thread Ian Lance Taylor
On Thu, Feb 1, 2018 at 7:02 AM, Amedee Van Gasse wrote: > > I am taking my first steps with Go and following the instructions on > https://golang.org/doc/install to the letter. > I am finding documentation issues that are reproducible on a clean system, I > can give exact steps to reproduce. > > T

Re: [go-nuts] Documentation issue on the Getting Started page

2018-02-01 Thread Ian Lance Taylor
On Thu, Feb 1, 2018 at 8:07 AM, Amedee Van Gasse wrote: > > On Thursday, February 1, 2018 at 4:59:32 PM UTC+1, Ian Lance Taylor wrote: >> >> On Thu, Feb 1, 2018 at 7:02 AM, Amedee Van Gasse >> wrote: >> > >> > I am taking my first steps with Go an

Re: [go-nuts] Does go programmers should handle syscall.EINTR all by themselves after go1.9 when writing disk files?

2018-02-02 Thread Ian Lance Taylor
On Fri, Feb 2, 2018 at 6:07 AM, rmfr wrote: > > Does go programmers should handle syscall.EINTR all by themselves after > go1.9 when writing disk files? > > I just noticed this commit > https://github.com/golang/go/commit/c05b06a12d005f50e4776095a60d6bd9c2c91fac#diff-b7452e0f27c15f140b5e86f88e2d43

Re: [go-nuts] Why is the omitted expression in a swtich code block a typed bool "true"?

2018-02-02 Thread Ian Lance Taylor
On Fri, Feb 2, 2018 at 7:10 AM, wrote: > > Why not make it untyped? > > package main > > type T bool > > func f() T {return T(false)} > > func main() { > switch { > case f(): // invalid case f() in switch (mismatched types T and bool) > } > } The current language spec says that omitt

Re: [go-nuts] Re: making common declarations for several packages?

2018-02-03 Thread Ian Lance Taylor
On Sat, Feb 3, 2018 at 9:36 AM, wrote: > You need the package name. > > var a *common.Any Yes. Let me add that some people consider "common" to be a poor choice for a package name. See https://github.com/golang/go/wiki/CodeReviewComments#package-names and the links there. Ian > On Saturday,

Re: [go-nuts] Re: Relaxing rules on slice comparison: would it make sense?

2018-02-06 Thread Ian Lance Taylor
On Tue, Feb 6, 2018 at 1:34 AM, roger peppe wrote: > ... tick, tick, tick, tick... dide-dudi-diddlidedum...di! > > func comparable(xs []int) interface{} { > type elem struct { > first int > rest interface{} > } > var r interface{} > for

Re: [go-nuts] Debug high GC pause frequency issue

2018-02-06 Thread Ian Lance Taylor
On Tue, Feb 6, 2018 at 12:58 AM, Bob Cao wrote: > > I have a program whose GC pause frequency will quickly go from 40 calls per > minute to 2000 calls per minute in a matter of hours, and the issue is kind > of random on production. > > Is there any advice on how to spot the cause of the issue? U

Re: [go-nuts] osx 10.12 all.bash weirdness with os/signal tests

2018-02-06 Thread Ian Lance Taylor
On Tue, Feb 6, 2018 at 2:28 PM, andrey mirtchovski wrote: > > I'm trying to understand why os/signal tests fail on my 10.12 macbook > pro at tip: > > $ ./all.bash > [...] > ok net/textproto (cached) > ok net/url (cached) > ok os 0.678s > ok os/exec 1.185s > --- FAIL: TestTerminalSignal (5.01s)

Re: [go-nuts] osx 10.12 all.bash weirdness with os/signal tests

2018-02-06 Thread Ian Lance Taylor
On Tue, Feb 6, 2018 at 2:54 PM, andrey mirtchovski wrote: > $ go test -c os/signal > $ ./signal.test > PASS > $ go tool dist test -v > > # Testing packages. > # go tool dist test -run=^go_test:archive/tar$ > [...] > ok net/url (cached) > ok os 0.677s > ok os/exec 1.414s > --- FAIL: TestTerm

Re: [go-nuts] Unexpect deadlock on select multi channel

2018-02-07 Thread Ian Lance Taylor
On Wed, Feb 7, 2018 at 6:24 AM, Damon Zhao wrote: > Anybody help with this issue (still not solved but I cannot reopen it) > > https://github.com/golang/go/issues/23728 The select statement works pseudo-randomly. You are sending two values on source. When the select statement chooses `worker :=

[go-nuts] Let's collect options to add to the whitelist in #23749

2018-02-08 Thread Ian Lance Taylor
There have been several different reports of options missing from the whitelist of cgo options that was just added to the go tool. I propose that we collect them all in https://golang.org/issue/23749 and then write a single CL that adds all the appropriate ones. That will give us an easy backport

Re: [go-nuts] how to link cgo libraries in go1.9.4 ?

2018-02-09 Thread Ian Lance Taylor
On Fri, Feb 9, 2018 at 10:05 AM, Jason E. Aten wrote: > Yay. I found a workaround--or rather, finally understood one of the > suggestions. > > Adding the following CGO_LDFLAGS_ALLOW hack in the Makefiles allows linking > against the named .a file. > > export > CGO_LDFLAGS_ALLOW="${GOPATH}/src/gith

Re: [go-nuts] type definitions and original types

2018-02-11 Thread Ian Lance Taylor
On Sun, Feb 11, 2018 at 7:52 AM, rajesh nataraja wrote: > > Yes I understand the strict type checking. But in the absence of macros, the > code becomes extremely awkward and sometimes the simplicity that we beg for > gets undermined. > My intention trying to do this was two things: > 1. Reduce my

Re: [go-nuts] Cross-compiling error for runtime package in go1.9.4 (works in go1.9.2)

2018-02-11 Thread Ian Lance Taylor
On Sun, Feb 11, 2018 at 1:00 PM, wrote: > > I'm building a package that depends on Go's runtime package. Using the > following compilation flags: > > CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 > > I get a successful compilation using go1.9.2. After updating to go1.9.4, I > get the following error an

Re: [go-nuts] Working with Floating-Point numbers

2018-02-12 Thread Ian Lance Taylor
On Mon, Feb 12, 2018 at 9:40 AM, go-question wrote: > > When working with Floating-point values in Go, what considerations need to > be made? > > The same for any other language? > > The Spec says that "Floating-point values are comparable and ordered" > https://golang.org/ref/spec#Comparison_oper

Re: [go-nuts] Pdeathsig alternate for other operating systems

2018-02-12 Thread Ian Lance Taylor
On Mon, Feb 12, 2018 at 5:18 PM, Amandeep Gautam wrote: > > I am writing a process monitoring solution in go for AIX. I would like to > signal the child process when the parent dies so that it does not become > orphaned. In linux, one can set PdeathSig > (https://golang.org/pkg/syscall/#SysProcAtt

Re: [go-nuts] Cross-compiling error for runtime package in go1.9.4 (works in go1.9.2)

2018-02-12 Thread Ian Lance Taylor
On Mon, Feb 12, 2018 at 7:44 PM, Matt R. wrote: > > I have a simple way to reproduce this with GOROOT defined for each golang > version. > > Install gb. https://getgb.io/ > Create a project with the structure: > > src > > app > > main.go (fill with contents of runtime example from documentation >

Re: [go-nuts] Okay to use mmap ?

2018-02-13 Thread Ian Lance Taylor
On Tue, Feb 13, 2018 at 1:00 AM, Jan Mercl <0xj...@gmail.com> wrote: > On Tue, Feb 13, 2018 at 12:40 AM wrote: > >> Note though that you can't put pointers to Go heap objects into mmap'd >> memory, as the garbage collector can't see them. > > It's possible, provided such pointers are known/guarant

Re: [go-nuts] How can I fetch the default locale (server locale not from the request) in Golang

2018-02-14 Thread Ian Lance Taylor
On Tue, Feb 13, 2018 at 11:19 PM, wrote: > > I'm a newbee to Golang and am trying to fetch the default server locale. > Can you help me how I can fetch the default server locale in golang? > > In other words, I'm looking for the Java equivalent code in golang i.e > 'Locale.getDefault()' Go doe

Re: [go-nuts] gccgo produces much slower code than gc

2018-02-14 Thread Ian Lance Taylor
On Wed, Feb 14, 2018 at 12:00 PM, Tamir Duberstein wrote: > Running the benchmarks in github.com/cockroachdb/cockroach/pkg/roachpb: > >> PATH=$HOME/local/go1.10/bin:$PATH >> go test -i ./pkg/roachpb && go test -run - -bench . ./pkg/roachpb -count 5 >> -benchmem > gc.txt >> >> PATH=$GCCROOT/gcc/bin

Re: [go-nuts] memory leak, heap size doesn't match process res size

2018-02-15 Thread Ian Lance Taylor
On Thu, Feb 15, 2018 at 7:21 AM, Kane Kim wrote: > > I was surprised to see that overhead is so significant, is there any way to > peek into that and see what is taking up space in race detector? I've tried > --inuse_objects in a heap dump, but didn't see anything suspicious there. The race detec

Re: [go-nuts] gccgo produces much slower code than gc

2018-02-15 Thread Ian Lance Taylor
On Thu, Feb 15, 2018 at 6:42 AM, Tamir Duberstein wrote: > Built at this revision: > https://github.com/gcc-mirror/gcc/commit/a82f431e184a9ac922ad43df73cdcc702ab0f279 Thanks. What do you see from go test -gccgoflags="-g -O2" ? Ian > On Wed, Feb 14, 2018 at 7:44 PM, Ian

Re: [go-nuts] gccgo produces much slower code than gc

2018-02-15 Thread Ian Lance Taylor
On Thu, Feb 15, 2018 at 10:59 AM, Ian Lance Taylor wrote: > On Thu, Feb 15, 2018 at 6:42 AM, Tamir Duberstein wrote: >> Built at this revision: >> https://github.com/gcc-mirror/gcc/commit/a82f431e184a9ac922ad43df73cdcc702ab0f279 > > Thanks. What do you see from > >

Re: [go-nuts] gccgo produces much slower code than gc

2018-02-15 Thread Ian Lance Taylor
>> ValueGetInt-16 0.00 0.00 ~ (all equal) >> ValueGetProto-160.00 0.00 ~ (all equal) >> ValueGetTime-16 0.00 0.00 ~ (all equal) >> ValueGetDecimal-16 1.00 ± 0% 1

Re: [go-nuts] How can I fetch the default locale (server locale not from the request) in Golang

2018-02-16 Thread Ian Lance Taylor
get it from the client. What operating system? What format do you want for the locale? Ian > On Wednesday, 14 February 2018 20:21:05 UTC+5:30, Ian Lance Taylor wrote: >> >> On Tue, Feb 13, 2018 at 11:19 PM, wrote: >> > >> > I'm a newbee to Golang

Re: [go-nuts] How can I fetch the default locale (server locale not from the request) in Golang

2018-02-16 Thread Ian Lance Taylor
On Fri, Feb 16, 2018 at 8:21 AM, Anish P wrote: > > I'm looking to fetch the IANA timezone. For what it's worth, I don't usually call the timezone a "locale". In programming, "locale" usually refers to language related issues. See https://en.wikipedia.org/wiki/Locale_(computer_software) . To g

Re: [go-nuts] Warning: Failure to Cross-Compile

2018-02-17 Thread Ian Lance Taylor
On Sat, Feb 17, 2018 at 8:54 AM, wrote: > Newbie here. Learning to program in Go... > > Just upgraded from 1.8.1 --> the wonderful 1.10; easy to do and smooth > (thank you Go Team!!!). Compiling is faster still! Question for the > congregants: > > I write my Go code on a Windows 10 box using V

Re: [go-nuts] Warning: Failure to Cross-Compile

2018-02-17 Thread Ian Lance Taylor
tag > get.metaImport{Prefix:"golang.org/x/tools", VCS:"git", > RepoRoot:"https://go.googlesource.com/tools"} at > https://golang.org/x/tools/go/ast/astutil?go-get=1 > get "golang.org/x/tools/go/ast/astutil": verifying non-authoritative meta > tag

Re: [go-nuts] Re: Go 1.10 is released

2018-02-18 Thread Ian Lance Taylor
On Sun, Feb 18, 2018 at 11:22 AM, Henrik Johansson wrote: > The GOCACHE variable. What is it's effect when building Go itself? > It doesn't disable test caching when using the resulting go tools right? Right. Ian -- You received this message because you are subscribed to the Google Groups "go

Re: [go-nuts] About Go Compiler!

2018-02-18 Thread Ian Lance Taylor
On Sun, Feb 18, 2018 at 9:23 AM, Compiler wrote: > #Question > > What is the difference between using the following two files? > > /go/src/cmd/gc/go.y > /go/src/cmd/cc/cc.y > > - > #Question > > What is the difference between using the following two files? > > /go/src/cmd/gc/lex.c > /g

Re: [go-nuts] Re: Go 1.10 is released

2018-02-19 Thread Ian Lance Taylor
> removed later on? Sorry, I don't know. I don't know who wrote that script or why it sets GOCACHE. Ian > sön 18 feb. 2018 kl 23:04 skrev Ian Lance Taylor : >> >> On Sun, Feb 18, 2018 at 11:22 AM, Henrik Johansson >> wrote: >> > The GOCACHE variable

Re: [go-nuts] intentional fmt spacing behavior in for statement initializer ?

2018-02-19 Thread Ian Lance Taylor
On Mon, Feb 19, 2018 at 11:11 AM, wrote: > https://play.golang.org/p/Pvhg_npsg3Y > > (padded with spaces - press fmt for output) > > > output : > > package main > > > import "fmt" > > > func main() { > > i, h, rs := 1, 1000, 160 > > > for y := i * (h / rs); y < (1+i)*(h/rs); y++ { > > fmt.Println

Re: [go-nuts] Re: Go 1.10 is released

2018-02-19 Thread Ian Lance Taylor
ther than always setting the GOCACHE environment variable every time you run the go tool. Ian > On Mon, Feb 19, 2018, 21:00 Ian Lance Taylor wrote: >> >> On Sun, Feb 18, 2018 at 11:00 PM, Henrik Johansson >> wrote: >> > >> > Why I wondered was because

Re: [go-nuts] Re: Go 1.10 is released

2018-02-19 Thread Ian Lance Taylor
ed not only to disable the cache but to set the cache's location. Ian > On Mon, Feb 19, 2018, 21:35 Ian Lance Taylor wrote: >> >> On Mon, Feb 19, 2018 at 12:08 PM, Henrik Johansson >> wrote: >> > Ah, that's not what I meant but GOCACHE var itself and if

Re: [go-nuts] Re: Tweaking sync.Pool for mostly-empty pools

2018-02-19 Thread Ian Lance Taylor
On Mon, Feb 19, 2018 at 4:56 AM, Chris Hopkins wrote: > > I would have expected the compiler to allowed to change: > if len(l.shared) > 0 { # the racy check for non-emptiness > l.Lock() > last := len(l.shared) - 1 > to > tmp := len(l.shared) > if tmp > 0 { # the racy check for non-emptiness >

Re: [go-nuts] Appropriate Go type for cgo void* param that accepts either an offset or pointer?

2018-02-19 Thread Ian Lance Taylor
On Mon, Feb 19, 2018 at 3:09 PM, Eric Woroshow wrote: > > Right, declaring the type as uintptr but requiring that the memory come from > C.malloc is workable, but definitely compromises ease-of-use. Typically the > pointer values are to data stored in slices, and per issue 13656 there does > not (

Re: [go-nuts] Re: import paths - slash vs backslash

2018-02-19 Thread Ian Lance Taylor
On Mon, Feb 19, 2018 at 9:15 PM, 'Tim Hockin' via golang-nuts wrote: > Pinging this topic - does anyone know? > > On Fri, Nov 10, 2017 at 10:30 AM, Tim Hockin wrote: >> Is it valid to say `import "github.com\foo\bar" (windows path >> separators) or must it be "github.com/foo/bar"? I couldn't fin

Re: [go-nuts] what was learned from the dep experiment

2018-02-21 Thread Ian Lance Taylor
On Wed, Feb 21, 2018 at 6:19 AM, Joseph Lorenzini wrote: > > So I read Russ Cox post and specifically noted this: > > "But once we understand the design space better and can narrow it down to > the few key features that must be supported, it will help the Go ecosystem > to remove the other feature

Re: [go-nuts] Build started to fail with 1.10

2018-02-22 Thread Ian Lance Taylor
On Thu, Feb 22, 2018 at 8:38 AM, Владислав Митов wrote: > > One of my build started failing with 1.10. Basically I'm building a wrapper > around a C library and it fails with: > > # runtime/cgo > gcc_libinit.c: In function '_cgo_try_pthread_create': > gcc_libinit.c:97:18: error: storage size of 't

Re: [go-nuts] http.shutdownPollInterval documentation

2018-02-22 Thread Ian Lance Taylor
On Thu, Feb 22, 2018 at 1:50 PM, Sridhar wrote: > > In https://golang.org/src/net/http/server.go the documentation for > shutdownPollInterval (admittedly unexported) reads: > > // Ideally we could find a solution that doesn't involve polling, > > // but which also doesn't have a high runtime cost

Re: [go-nuts] All goroutines hung in futex / sleep

2018-02-22 Thread Ian Lance Taylor
On Thu, Feb 22, 2018 at 5:48 PM, Michael Andersen wrote: > > I have a complex program that when under load will very reproducibly freeze > every goroutine simultaneously. It then makes no progress at all, even if > left for hours. I'm posting here because I don't know of anything that can > cause

Re: [go-nuts] "golang.org/x/net/internal/iana" //use of internal package not allowed

2018-02-23 Thread Ian Lance Taylor
On Fri, Feb 23, 2018 at 2:10 AM, wrote: > > "golang.org/x/net/internal/iana" //use of internal package not allowed > > how to import You can't. It's not allowed. What are you really trying to do? Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts"

Re: [go-nuts] All goroutines hung in futex / sleep

2018-02-23 Thread Ian Lance Taylor
On Fri, Feb 23, 2018 at 1:19 AM, Michael Andersen wrote: > > Ok I found the problem. A tight loop was indeed preventing the garbage > collector from proceeding, and then the GC was stopping everything else. The > loop contained atomic.LoadUint64 and atomic.CompareAndSwapUint64, but > neither of th

Re: [go-nuts] Appreciating Go

2018-02-23 Thread Ian Lance Taylor
On Fri, Feb 23, 2018 at 5:23 PM, Bakul Shah wrote: > > I once worked out some details of adding sum types to Go and I > think it is quite doable and easy to implement. There is an extensive discussion of sum types in Go over at https://golang.org/issue/19412. Ian -- You received this message b

Re: [go-nuts] Vgo and reproducable builds

2018-02-26 Thread Ian Lance Taylor
On Mon, Feb 26, 2018 at 8:29 AM, Johann Höchtl wrote: > > Right at the beginning of the first post about vgo it is stated: > >> Versioning will also let us ensure that a program builds exactly the same >> way tomorrow as it does today. Even when there are newer versions of my >> dependencies, th

Re: [go-nuts] Is there some kind of memory write protection mechanism?

2018-02-26 Thread Ian Lance Taylor
On Mon, Feb 26, 2018 at 9:42 AM, wrote: > > On Monday, February 26, 2018 at 12:35:13 PM UTC-5, Jakob Borg wrote: >> >> On 26 Feb 2018, at 18:21, "di...@veryhaha.com" wrote: >> >> On Monday, February 26, 2018 at 11:48:36 AM UTC-5, Jakob Borg wrote: >>> >>> On 26 Feb 2018, at 16:38, di...@veryhaha

Re: [go-nuts] NOSPLIT on Go assembler defined functions

2018-02-26 Thread Ian Lance Taylor
On Sun, Feb 25, 2018 at 11:27 PM, Pablo Rozas Larraondo wrote: > > I started learning about Go assembler and I'm having problems with the > NOSPLIT symbol, which makes the compilation fail with error message: > "illegal or missing addressing mode for symbol NOSPLIT" > > I've found a blog post whic

Re: [go-nuts] How to interpret runtime._ExternalCode in a profile?

2018-02-26 Thread Ian Lance Taylor
es me curious: would it be feasible to make the profiler >> recognize a vDSO call and synthesize a more helpful stack? >> >> On Sun, Feb 25, 2018 at 3:39 PM, Ian Lance Taylor >> wrote: >> >>> On Sun, Feb 25, 2018 at 3:30 PM, Caleb Spare wrote: >>> >

Re: [go-nuts] How to interpret runtime._ExternalCode in a profile?

2018-02-26 Thread Ian Lance Taylor
On Mon, Feb 26, 2018 at 12:55 PM, Ian Lance Taylor wrote: > On Sun, Feb 25, 2018 at 8:04 PM, Dave Cheney wrote: > >> I don't understand how that could happen. time.Now calls time.now (which >> is in assembly) so the former shouldn't be inlined, or omitted from &

Re: [go-nuts] Is there some kind of memory write protection mechanism?

2018-02-26 Thread Ian Lance Taylor
On Mon, Feb 26, 2018 at 7:20 PM, wrote: > > On Monday, February 26, 2018 at 2:24:39 PM UTC-5, Ian Lance Taylor wrote: >> >> On Mon, Feb 26, 2018 at 9:42 AM, wrote: >> > >> > On Monday, February 26, 2018 at 12:35:13 PM UTC-5, Jakob Borg wrote: >&

Re: [go-nuts] Getting an unsafe.Pointer to a []byte's underlying array?

2018-02-28 Thread Ian Lance Taylor
On Wed, Feb 28, 2018 at 1:58 PM, wrote: > > What is the best way to get an unsafe.Pointer to a []byte's underlying > array? unsafe.Pointer(&b[0]) > I have added this function to syscall/syscall_linux.go to support some of > our experiments. One of the new getsockopt calls returns a variable le

Re: [go-nuts] w, x += i, i+i

2018-02-28 Thread Ian Lance Taylor
On Wed, Feb 28, 2018 at 4:53 PM, Alex Dvoretskiy wrote: > > When I'm doing assignments to multiple variables in one line, there is a > limitation. > > > You can do it in this way: > w, x = w+i, x+i+i > > But can't in this one: > w, x += i, i+i > > > What do you think, it was done on purpose or thi

Re: [go-nuts] High precision timer data?

2018-03-01 Thread Ian Lance Taylor
On Thu, Mar 1, 2018 at 8:56 AM, James Chacon wrote: > > I know the time package includes support for using the cycle timer on the > machine (if available) to get high precision monotonic time measurements. > > But...calling time.Now() appears to have a lot of overhead. Measuring the > delay betwee

Re: [go-nuts] When an object is KeepAlived, will other objects referenced by it also be KeepAlived?

2018-03-01 Thread Ian Lance Taylor
On Thu, Mar 1, 2018 at 8:29 AM, wrote: > > For example, > > func f(s []byte) { > > // Will the the KeepAlive call make sure the underlying bytes > // of s will not garbage collected for sure? > > runtime.KeepAlive(&s) > } Yes, this will ensure that the bytes in s will be live, and no

Re: [go-nuts] Re: When an object is KeepAlived, will other objects referenced by it also be KeepAlived?

2018-03-01 Thread Ian Lance Taylor
On Thu, Mar 1, 2018 at 9:04 AM, wrote: > > Is the KeepAlive call in the following example essential? and sufficient? > > func ByteSlice2String(bs []byte) (str string) { > sliceHdr := (*reflect.SliceHeader)(unsafe.Pointer(&bs)) > strHdr := (*reflect.StringHeader)(unsafe.Pointer(&str)) >

Re: [go-nuts] should the reflect docs explain what do the Data fields mean in SliceHeader and StringHeader?

2018-03-01 Thread Ian Lance Taylor
On Thu, Mar 1, 2018 at 9:08 AM, wrote: > If not, it is hard to use them in meaningful ways. The docs already say that the each type "cannot be used safely or portably and its representation may change in a later release." I don't think we need to say anything else. Ian -- You received this m

Re: [go-nuts] [Question]: Are there any plans to teach the compiler to emit VEX encoded instructions ?

2018-03-01 Thread Ian Lance Taylor
On Thu, Mar 1, 2018 at 5:05 AM, Agniva De Sarker wrote: > > I believe using the non-destructive 3 operand form will help a lot in > reducing the size of binaries. And also, it might give us a good base to add > FMA support and SIMD optimizations later. > > I have been adding fast paths to some mat

Re: [go-nuts] Memory copy on return statement (copy elision)

2018-03-04 Thread Ian Lance Taylor
On Sun, Mar 4, 2018 at 5:57 AM, Bruno Novais wrote: > > As you probably noticed by my question, I'm new to this awesome language > called Go (coming from C/C++). In C++ I rely a lot on constructor (copy) > elision. I think Go doesn't have this concept, but I would like to know what > happen when I

Re: [go-nuts] osx 10.12 all.bash weirdness with os/signal tests

2018-03-05 Thread Ian Lance Taylor
a history file could cause the test to take more than 5 seconds. That said, setting HISTFILE is probably a good idea anyhow. I think it should work to set it to the empty string, which would be slightly better than /dev/null. Thanks. Ian > On Tue, Feb 6, 2018 at 4:20 PM, Ian Lan

Re: [go-nuts] How to get an alias in a type alias ???

2018-03-05 Thread Ian Lance Taylor
On Mon, Mar 5, 2018 at 1:35 AM, He Liu wrote: > > package main > > > import ( > > "log" > > "reflect" > > ) > > > type AAA = int > > > func main() { > > var a AAA = 5 > > x := reflect.TypeOf(a) > > log.Println(x.Name()) > > // print int > > } > > > How to get AAA ??? You can't. A type alias is j

Re: [go-nuts] Re: confusing differences in reflect Type knowledge for a receiver vs. an argument

2018-03-05 Thread Ian Lance Taylor
On Mon, Mar 5, 2018 at 8:08 PM, Randall O'Reilly wrote: > Thank you for that clarification of what is happening under the hood. > > Nevertheless, I do think there are many cases where it would be very valuable > to have access through reflect of the true underlying type of the receiver > struct.

Re: [go-nuts] Re: confusing differences in reflect Type knowledge for a receiver vs. an argument

2018-03-06 Thread Ian Lance Taylor
On Mon, Mar 5, 2018 at 9:53 PM, Randall O'Reilly wrote: > On Mar 5, 2018, at 10:32 PM, Ian Lance Taylor wrote: >> >> Go doesn't have anything like inheritance in C++. What you are >> calling the "true underlying type" simply doesn't exist in

Re: [go-nuts] Undocumented behaviour - panic exiting with exit code 2?

2018-03-06 Thread Ian Lance Taylor
On Tue, Mar 6, 2018 at 3:55 PM, Rob Pike wrote: > That's poor. Exit code 2 is supposed to mean 'incorrect arguments' in the > Unix tradition. > > Something like 127 or 255 would be better. I think you actually set it to 2, back in June, 2008, in what is now known as git revision aeb43984ec7c86aee

Re: [go-nuts] Re: why is the "1" in the code demoed in Go spec deduced as a "float64" value instead of an "int" value?

2018-03-07 Thread Ian Lance Taylor
On Wed, Mar 7, 2018 at 12:54 PM, Volker Dobler wrote: > Looks suspicious. Without crosschecking the Spec: Might be > a bug. File an issue? It's not a bug. See Andrey's reply. Ian > On Wednesday, 7 March 2018 21:39:32 UTC+1, di...@veryhaha.com wrote: >> >> var s uint = 33 >> var u2 = float64

Re: [go-nuts] Re: why is the "1" in the code demoed in Go spec deduced as a "float64" value instead of an "int" value?

2018-03-07 Thread Ian Lance Taylor
32 = 1 << s fails because we can't shift a float32. We could ignore the type context for float types but not for integer types, but then the rule is even more complicated. Ian >> On Wednesday, March 7, 2018 at 3:59:48 PM UTC-5, Ian Lance Taylor wrote: >>> >>&

Re: [go-nuts] Building Go

2018-03-08 Thread Ian Lance Taylor
On Thu, Mar 8, 2018 at 3:53 AM, Krzysztof Kwiatkowski wrote: > > > I've quite newbe question, but I would like to double-check my understanding > before doing something stupid. > > > I'm building a toolchain for which I need to compile go from sources (I > modify the sources). In order to compile

Re: [go-nuts] Debugging unit tests in go

2018-03-08 Thread Ian Lance Taylor
On Thu, Mar 8, 2018 at 4:41 AM, wrote: > > How can I debug the unit tests in go ? Normal executible I debug with gdb or > delve. > I am running from command prompt go test -v ./test/... -run Test_Connect. Run `go -test c PKG` to get an executable for the package PKG. You can then run that exec

Re: [go-nuts] Are the semicolons rules some weird?

2018-03-08 Thread Ian Lance Taylor
On Thu, Mar 8, 2018 at 8:43 AM, wrote: > > There are two semicolon rules in Go spec: > https://golang.org/ref/spec#Semicolons > The first one states how a semicolon will be automatically inserted, > however, the second one states how a semicolon can be omitted. > Isn't more consistent to modify t

Re: [go-nuts] Are the semicolons rules some weird?

2018-03-08 Thread Ian Lance Taylor
On Thu, Mar 8, 2018 at 9:13 AM, wrote: > > On Thursday, March 8, 2018 at 11:49:18 AM UTC-5, Ian Lance Taylor wrote: >> >> On Thu, Mar 8, 2018 at 8:43 AM, wrote: >> > >> > There are two semicolon rules in Go spec: >> > https://golang.org/ref/sp

Re: [go-nuts] Are the semicolons rules some weird?

2018-03-08 Thread Ian Lance Taylor
On Thu, Mar 8, 2018 at 9:14 AM, wrote: > btw, are there any cases a semicolon may be omitted before a closing ")"? var ( a = 1 ) Ian > On Thursday, March 8, 2018 at 11:49:18 AM UTC-5, Ian Lance Taylor wrote: >> >> On Thu, Mar 8, 2018 at 8:43 AM, wrote: >&

Re: [go-nuts] Multiple directory paths in $GOPATH and go get

2018-03-09 Thread Ian Lance Taylor
On Fri, Mar 9, 2018 at 5:12 AM, Kaveh Shahbazian wrote: > Thanks! > > The reason for this question: wanted to have one $GOPATH/bin but different > $GOPATH/src. You may be able to use the GOBIN environment variable to do this. See `go help gopath`. Ian > On Friday, March 9, 2018 at 4:33:24 PM

Re: [go-nuts] glr support in goyacc?

2018-03-09 Thread Ian Lance Taylor
On Fri, Mar 9, 2018 at 12:27 AM, David Wahlstedt wrote: > > But it would still be nice to have GLR in goyacc, for instance in order to > write an ASN.1 parser. I'm not aware of anybody working on that. Ian -- You received this message because you are subscribed to the Google Groups "golang-nu

Re: [go-nuts] What major API change really is?

2018-03-09 Thread Ian Lance Taylor
On Fri, Mar 9, 2018 at 6:39 AM, Maxim Ivanov wrote: > > Side question, would hyptohetical future generics substantially > reduce number of API breaking changes? I don't really see how. In a language like Go, I think that any plausible definition of generics implies adding type parameters to a fu

Re: [go-nuts] https://golang.org/pkg/crypto/tls/#example_Dial does not work

2018-03-12 Thread Ian Lance Taylor
On Sun, Mar 11, 2018 at 10:10 PM, Chokchai Phatharamalai wrote: > > Repro steps: > 1. visit https://golang.org/pkg/crypto/tls/#example_Dial > 2. press Run > > observed: > > panic: failed to connect: dial tcp: Protocol not available The sandbox used to execute examples hosted on golang.org does no

Re: [go-nuts] Why not add unsafe.FreeMemory(unsafe.Pointer) to replace sync.Pool ?

2018-03-14 Thread Ian Lance Taylor
On Wed, Mar 14, 2018 at 8:50 AM, bronze man wrote: > > I just found that sync.Pool is almost equal to calloc/free in c language to > program except that forgot call free will not cause a memory leak. I wouldn't say that. Calling Pool.Put reserves the memory for that specific pool, unlike free wh

Re: [go-nuts] Unexpected output on playground

2018-03-14 Thread Ian Lance Taylor
On Wed, Mar 14, 2018 at 9:33 AM, andrey mirtchovski wrote: > > wanted: panic: runtime error: invalid memory address or nil pointer > dereference > [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1090432] > > got: ** Signal 11 from untrusted code: pc=6559000898c0 > > is this just a

Re: [go-nuts] Goroutines, Nonblocking I/O, And Memory Usage

2018-03-14 Thread Ian Lance Taylor
On Wed, Mar 14, 2018 at 11:58 AM, Rio wrote: > > While implementing a SOCKS proxy in Go, I ran into an issue which is better > explained in details by Evan Klitzke in this post > https://eklitzke.org/goroutines-nonblocking-io-and-memory-usage > > In my case, each proxied connection costs two gorou

Re: [go-nuts] evacuate in hashmap: where to put when migrate data from oldbucket to bucket

2018-03-15 Thread Ian Lance Taylor
On Thu, Mar 15, 2018 at 1:34 AM, wrote: > > when evacuate oldbucket, go will migrate the data to a new position. > > and i found it used X and Y as two bucket where Xi equal the old index in > h.oldbuckets and Yi equal Xi plus newbit > > suppose the length of oldbuckets is 8 , and the hash of a k

Re: [go-nuts] About 64bits alignment

2018-03-15 Thread Ian Lance Taylor
On Thu, Mar 15, 2018 at 8:11 AM, T L wrote: > > On Thursday, March 15, 2018 at 10:57:50 AM UTC-4, Jan Mercl wrote: >> >> >> On Thu, Mar 15, 2018 at 3:29 PM T L wrote: >> >> > I mean "always makes 64-bit words 64-bit aligned on i386 OSes." >> >> AFAIK, that's not the case, ie. not always. >> >> --

Re: [go-nuts] Goroutines, Nonblocking I/O, And Memory Usage

2018-03-15 Thread Ian Lance Taylor
On Thu, Mar 15, 2018 at 8:58 AM, Rio wrote: > > On Thursday, March 15, 2018 at 3:37:51 AM UTC+8, Ian Lance Taylor wrote: >> >> >> Even for TCP, that's an interesting point. I wonder if we should have >> a way to specify a number of bytes to read such that

Re: [go-nuts] Goroutines, Nonblocking I/O, And Memory Usage

2018-03-15 Thread Ian Lance Taylor
On Thu, Mar 15, 2018 at 12:04 PM, Rio wrote: > > On Friday, March 16, 2018 at 1:05:12 AM UTC+8, Ian Lance Taylor wrote: >> >> >> That's inherently racy, though. It's quite normal to have multiple >> goroutines reading from the same socket. That is awk

Re: [go-nuts] Closing os.Stdin while trying to read from it?

2018-03-16 Thread Ian Lance Taylor
On Fri, Mar 16, 2018 at 5:29 AM, Alex Efros wrote: > > On Thu, Mar 15, 2018 at 12:49:15PM +, roger peppe wrote: >> If it helps, you can set deadlines on *os.File now, as of Go 1.10: >> >>https://play.golang.org/p/h3Pg9Ql0CMB >> >> I don't see a way to cancel without deciding the deadline i

Re: [go-nuts] getting an error for simple go program with for loop in MAC OSX 10.13.13

2018-03-16 Thread Ian Lance Taylor
Please file a bug at https://golang.org/issue, including all the information on the template. Thanks. Ian On Fri, Mar 16, 2018 at 5:15 AM, avinash dhananjaya < avinash.dhanan...@gmail.com> wrote: > > Hello All, > > I am getting a below error in MAC OSX 10.13.13. I am using 1.10 version. > > go/

Re: [go-nuts] implementation of sync.atomic primitives

2018-03-18 Thread Ian Lance Taylor
On Sun, Mar 18, 2018 at 9:47 PM, shivaram via golang-nuts wrote: > > I noticed that internally, the language implementation seems to rely on the > atomicity of reads to single-word values: > > https://github.com/golang/go/blob/bd859439e72a0c48c64259f7de9f175aae3b9c37/src/runtime/chan.go#L160 In t

Re: [go-nuts] implementation of sync.atomic primitives

2018-03-19 Thread Ian Lance Taylor
On Mon, Mar 19, 2018 at 5:46 AM, shivaram via golang-nuts wrote: > > 2. The property that word-sized values are not subject to > interleaving/tearing is an implementation detail, rather than a guarantee of > the Go memory model? My impression is that that is guaranteed by the Go memory model. Bu

Re: [go-nuts] Necessary to use sync.pool for gc in golang 1.9

2018-03-20 Thread Ian Lance Taylor
On Mon, Mar 19, 2018 at 10:51 PM, 芮峰云 wrote: > Necessary to use sync.pool for gc in golang 1.9 ? No. It's never necessary to use sync.Pool. sync.Pool is a special purpose mechanism for more efficient handling of certain memory allocation patterns. It is not a general purpose tool. Ian -- Yo

Re: [go-nuts] About argument evaluation order.

2018-03-20 Thread Ian Lance Taylor
On Tue, Mar 20, 2018 at 8:45 AM, T L wrote: > The Go specification only says > > In a function call, the function value and arguments are evaluated in the > usual order. > > The usual order is explained here: > https://tip.golang.org/ref/spec#Order_of_evaluation > But I am not clear on what the us

Re: [go-nuts] Re: About argument evaluation order.

2018-03-20 Thread Ian Lance Taylor
On Tue, Mar 20, 2018 at 8:52 AM, T L wrote: > BTW, another problem: > are the function calls appearing in a composite literal evaluated by their > lexical left-to-right order? Assuming you mean something like []int{f(), g(), h()}, then, yes. The order of function calls must be f(), g(), h(). Ia

Re: [go-nuts] Re: About argument evaluation order.

2018-03-20 Thread Ian Lance Taylor
On Tue, Mar 20, 2018 at 10:30 AM, Jan Mercl <0xj...@gmail.com> wrote: > On Tue, Mar 20, 2018 at 6:19 PM T L wrote: > >> Yes "1 1 2" is the output of gc, but I can't find any guarantees made for >> this output in Go specification. > > The guarantee was mentioned: LTR evaluation order as seen in the

Re: [go-nuts] implementation of sync.atomic primitives

2018-03-20 Thread Ian Lance Taylor
27;s not a race. The memory model explains what a race is, and it pretty clearly includes cases like your example. Ian > On Monday, March 19, 2018 at 8:59:15 PM UTC-4, Ian Lance Taylor wrote: >> >> On Mon, Mar 19, 2018 at 5:46 AM, shivaram via golang-nuts >> wrote: >> >

Re: [go-nuts] implementation for GetsockoptLinger() and GetsockoptTimeval()

2018-03-23 Thread Ian Lance Taylor
On Fri, Mar 23, 2018 at 3:43 PM, yuxuanli via golang-nuts wrote: > > I am using the x/sys/unix package to get the socket options of a fd. While > there are SetsockoptLinger() and SetsockoptTimeval() for setting the Linger > and Timeout options, there is no corresponding getter for them. I wonder i

Re: [go-nuts] Tail call optimization

2018-03-27 Thread Ian Lance Taylor
On Tue, Mar 27, 2018 at 12:05 AM, Linker Lin wrote: > become +1 > TCO is very important for porting other FP lang to Go. This is https://golang.org/issue/22624. Ian > On Monday, February 14, 2011 at 4:25:24 AM UTC+8, Eoghan Sherry wrote: >> >> On 13 February 2011 08:51, chris dollin wrote: >>

Re: [go-nuts] Windows cgo complier

2018-03-28 Thread Ian Lance Taylor
On Wed, Mar 28, 2018 at 6:17 AM, Luke Mauldin wrote: > Can someone please tell me what the golang team uses as the reference windows > x64 compiler? I have heard references to mingw64 but it would be helpful to > know the exact version they are using for their unit tests on Windows. I am > expe

Re: [go-nuts] Why is the output different for this program?

2018-03-28 Thread Ian Lance Taylor
On Wed, Mar 28, 2018 at 9:04 AM, Nilsocket wrote: > > package main > > import ( > "fmt" > "unsafe" > ) > > func main() { > showString("12345") > } > > func showString(s string) { > res := *(*[unsafe.Sizeof(s)]byte)(unsafe.Pointer(&s)) > fmt.Println(s, res, []byte(s)) > for

  1   2   3   4   5   6   7   8   9   10   >