Re: [go-nuts] undefined and implementation defined behavior in Go

2019-02-19 Thread Ian Lance Taylor
On Tue, Feb 19, 2019 at 1:56 PM Manlio Perillo wrote: > > The Go specification do use both implementation-dependent and > implementation-defined, and I assumed it was a typo. > But what is the difference between implementation-dependent and > implementation-defined? I don't think they are used

Re: [go-nuts] How can I try debug.SetMaxHeap?

2019-02-20 Thread Ian Lance Taylor
[ +austin ] On Wed, Feb 20, 2019 at 11:11 AM 'Vinicius Fortuna [vee-NEE-see.oos]' via golang-nuts wrote: > > My team is struggling with limiting the head size of a Go application and > would like to know how to use SetMaxHeap. > > We wrote a VpnExtension for iOS which gets killed by the OS if is

Re: [go-nuts] efficient random float32 number generator?

2019-02-25 Thread Ian Lance Taylor
On Mon, Feb 25, 2019 at 2:01 PM DrGo wrote: > > what is the fastest possible algorithm to generate a float32 pseudo-random > number in [0.0,1.0)? > need to generate billions of numbers. Statistical performance and security > (and even space) are not a priority. > any Go implementations you know

Re: [go-nuts] Generics: the less obvious *constraints*, and the relationship to exception/error handling

2019-02-25 Thread Ian Lance Taylor
On Mon, Feb 25, 2019 at 4:17 PM Louki Sumirniy wrote: > > It didn't occur to me until I was thinking about the issues raised in > constructing a bundle of compound literals to define the parameters for > multi-command CLI applications that such declarations really have to be > sanitised just li

Re: [go-nuts] Section(".gosymtab") vs SectionByType(elf.SHT_SYMTAB)

2019-02-26 Thread Ian Lance Taylor
On Tue, Feb 26, 2019 at 12:51 PM wrote: > > In the debug/elf library(https://golang.org/pkg/debug/elf/), there are two > calls for getting the symbol table. To me it seems like these two calls > should be equivalent, both fetching the symbol table. But when I run these I > get two different ans

Re: [go-nuts] distribution of go executables

2019-02-26 Thread Ian Lance Taylor
On Tue, Feb 26, 2019 at 10:59 AM R Srinivasan wrote: > > what if any are the licensing requirements to distribute a "go" produced > executable? See https://go.googlesource.com/go/+/refs/heads/master/LICENSE . The requirements are minimal. > are there any "commercial" products built with go? Y

Re: [go-nuts] Re: Go 1.12 is Released

2019-02-26 Thread Ian Lance Taylor
On Tue, Feb 26, 2019 at 4:04 PM Camilo Aguilar wrote: > > Congrats and thank you for a new release! > > I was trying to build it from source and ran into the following error, any > hints about what I'm missing are appreciated: Odd. Please open a bug report at https://golang.org/issue/new. Than

Re: [go-nuts] Section(".gosymtab") vs SectionByType(elf.SHT_SYMTAB)

2019-02-26 Thread Ian Lance Taylor
On Tue, Feb 26, 2019 at 6:08 PM Gargi Sharma wrote: > > I meant the Section and SectionByType calls. Those calls do different things. They do more than just get the symbol table. They aren't equivalent. > [ 6] .gosymtab PROGBITS 004d7758 000d7758 >

Re: [go-nuts] distribution of go executables

2019-02-27 Thread Ian Lance Taylor
On Wed, Feb 27, 2019 at 6:56 AM Space A. wrote: > > Regarding runtime - it's interesting (and separate question maybe), and I > would argue that runtime IS part of language itself because language is not > only a syntax. It also a garbage collector, a goroutines, etc, as you > mentioned. You ju

Re: [go-nuts] Section(".gosymtab") vs SectionByType(elf.SHT_SYMTAB)

2019-02-27 Thread Ian Lance Taylor
On Wed, Feb 27, 2019 at 9:41 AM Gargi Sharma wrote: > > On Tue, Feb 26, 2019 at 11:34 PM Ian Lance Taylor wrote: > > > > On Tue, Feb 26, 2019 at 6:08 PM Gargi Sharma wrote: > > > > > > I meant the Section and SectionByType calls. > > > > Those ca

Re: [go-nuts] sync/atomic suggestion

2019-02-27 Thread Ian Lance Taylor
On Wed, Feb 27, 2019 at 12:46 PM Serhat Şevki Dinçer wrote: > > I would like to update a counter up to a certain limit atomically, without > using a channel or mutex. What do you think of the following (equivalent) > functions for sync/atomic? > > func CompareAndInc(*addr, Max) bool { > > if *

Re: [go-nuts] Is Go a single pass compiler?

2019-02-27 Thread Ian Lance Taylor
On Wed, Feb 27, 2019 at 2:42 PM wrote: > > In Go functions can be used before they are defined, but as I understand, > it's still possible to have a single pass compiler. I don't think it's possible to compile Go in a single pass compiler, unless you consider a separate parsing and code generati

Re: [go-nuts] does assembly pay the cgo transition cost / does runtime.LockOSThread() make CGO calls faster?

2019-03-01 Thread Ian Lance Taylor
On Fri, Mar 1, 2019 at 8:13 AM Jason E. Aten wrote: > > If I include a chunk of assembly .s code in my Go code, does my program pay > the CGO transition cost of locking and changing to a C stack? No. The assembly function is simply called just as a Go function is called. > I'm pretty sure the

Re: [go-nuts] does assembly pay the cgo transition cost / does runtime.LockOSThread() make CGO calls faster?

2019-03-01 Thread Ian Lance Taylor
On Fri, Mar 1, 2019 at 2:37 PM Jason E. Aten wrote: > > On Friday, March 1, 2019 at 4:13:49 PM UTC-6, Ian Lance Taylor wrote: >> >> Go assembly code is compiled by the Go assembler, cmd/asm. The author >> of the assembly code is required to specify how much stack space

Re: [go-nuts] go vet tool

2019-03-04 Thread Ian Lance Taylor
On Sun, Mar 3, 2019 at 11:02 PM wrote: > > Is it possible to use go vet as go tool vet . With go vet > it is giving no go source files, to use vet tool every time i have to go > different paths. Is there any way to use go vet as go tool vet. With go tool > vet I can be able to see log of all t

Re: [go-nuts] Can Go 2.x (or later) adopt some concurrency safety paradigms from Rust?

2019-03-04 Thread Ian Lance Taylor
On Mon, Mar 4, 2019 at 11:06 AM wrote: > > Paradigms of Rust for the Go developer > https://medium.com/@deckarep/paradigms-of-rust-for-the-go-developer-210f67cd6a29 > > I found this article extremely interesting. Concurrency safety appears to be > an area where Rust beats Go. > > I don't have an

Re: [go-nuts] Naming convention of low-level functions from runtime and everything

2019-03-04 Thread Ian Lance Taylor
On Mon, Mar 4, 2019 at 8:00 AM Michel Levieux wrote: > > I just have a little question here: sometimes reading the low-level code of > Go (like runtime, compiler code etc) I find the names of structs and fields > quite hard to understand, like acronyms or abreviations or even initials that > ar

Re: [go-nuts] go vet tool

2019-03-04 Thread Ian Lance Taylor
ang.org/cmd/go/#hdr-Package_lists_and_patterns if you read carefully. Ian > On Tue, Mar 5, 2019 at 6:20 AM Ian Lance Taylor wrote: >> >> On Sun, Mar 3, 2019 at 11:02 PM wrote: >> > >> > Is it possible to use go vet as go tool vet . With go >> > vet it is

Re: [go-nuts] How to understand "Binary-only packages"

2019-03-05 Thread Ian Lance Taylor
On Tue, Mar 5, 2019 at 9:16 AM ruinxs b wrote: >> >> Go 1.12 is the last release that will support binary-only packages. > > https://golang.org/doc/go1.12#binary-only > I am not very clear what "binary-only packages" means. Given that they may be going away, does it really matter? They are docum

Re: [go-nuts] Struct's fields order affects required memory

2019-03-06 Thread Ian Lance Taylor
On Wed, Mar 6, 2019 at 5:39 AM Viktor Packhuchyi wrote: > > As I know Go compiler provide self-managed alignment for fields inside a > structure. > > I don't understand why the fields order must impact additional allocations. > It's not clear for me, why the compiler doesn't manage this automatic

[go-nuts] Re: Go get fails for long paths #30623

2019-03-06 Thread Ian Lance Taylor
On Wed, Mar 6, 2019 at 3:30 AM Jan Mercl <0xj...@gmail.com> wrote: > > To someone owning a github account: Please forward to the issue tracker, > while there's still no bot for that, thanks in advance. Done. Thanks. > @Ian Lance Taylor: Last time we've discussed

Re: [go-nuts] Re: Should IP.DefaultMask() exist in today's Internet?

2019-03-07 Thread Ian Lance Taylor
On Thu, Mar 7, 2019 at 2:42 PM John Dreystadt wrote: > > I have not seen any response to my last posting yet, and I think it is still > an open question. I also realized an additional point that I should have > pointed out before which is that this is an IPv4 only thing. Which means that > I re

Re: [go-nuts] I have an issue in go after make

2019-03-08 Thread Ian Lance Taylor
On Fri, Mar 8, 2019 at 5:09 AM Nada Saif wrote: > > Hi, I am installing a dev environment on ubuntu vm. > The installation went well but at the end I got a messsage "/bin/sh :go not > found" > > Go is installed, I also added the path to .bashrc file > > go version > go version go1.12 linux/amd64

Re: [go-nuts] non-local return?

2019-03-08 Thread Ian Lance Taylor
On Fri, Mar 8, 2019 at 5:02 AM whitehexagon via golang-nuts wrote: > > I'm really liking in Go that I can easily pass bits of code around, > 'closures'? Apologies if I have terminology wrong, since I'm new here. > > For a typical asynchronous bit of code I like to pass in a 'func' for what to >

Re: [go-nuts] Debugging & breakpoints in Go compiler source code

2019-03-08 Thread Ian Lance Taylor
On Fri, Mar 8, 2019 at 4:23 PM Mohit Verma wrote: > > I was looking to see how the golang compiler works, and wanted to step in to > the compilation process to see what happens. I am looking at the standard Go > compiler in src/cmd/compile from https://github.com/golang/go. > > When I try to run

Re: [go-nuts] go directive in go.mod

2019-03-08 Thread Ian Lance Taylor
On Fri, Mar 8, 2019 at 4:42 PM wrote: > > I am an engineer working on Heroku's Go buildpack. > > Our buildpack needed a way for users to select the version of Go that they > wanted to build their code, so a “hacky” solution of using build tag like > constructs was implemented: > https://github.

Re: [go-nuts] Pointer declaration syntax

2019-03-10 Thread Ian Lance Taylor
On Sun, Mar 10, 2019 at 7:41 AM 박민우 wrote: > > I am new to Go and I have read Go;s-declaration-syntax documentation. > > It states that: > > p: pointer to int > > Would be written as: > p *int > > However, other than declaration syntax, "&" is the symbol for "the pointer > to" like, > q := &int >

Re: [go-nuts] sync/atomic and zero-initialization

2019-03-10 Thread Ian Lance Taylor
On Sun, Mar 10, 2019 at 7:54 PM shivaram via golang-nuts wrote: > > Can users of sync/atomic assume that memory will initially be zeroed? Or is > it necessary for a manual zeroing (using the atomic store operations) to > happen-before any reads? > > Context: https://github.com/golang/go/issues/5

Re: [go-nuts] [CoC] screenshot images. Lazines or incompetence?

2019-03-11 Thread Ian Lance Taylor
On Mon, Mar 11, 2019 at 5:22 AM Wojciech S. Czarnecki wrote: > > On Mon, 11 Mar 2019 07:39:40 -0400 > Sameer Ajmani wrote: > > > I believe calling fellow community members lazy or incompetent > > violates our Code of Conduct. > > Q.E.D. > > > Please endeavor to restate your concern in a way that

Re: [go-nuts] Debugging & breakpoints in Go compiler source code

2019-03-11 Thread Ian Lance Taylor
am just building it through make.bash from the src/ directory. You do not need to build the Go compiler differently in order to debug it. Unfortunately I do not know what this problem is. I haven't seen this problem. You could try running Delve instead, though I don't know whether it

Re: [go-nuts] aafaf

2019-03-11 Thread Ian Lance Taylor
On Mon, Mar 11, 2019 at 12:17 PM T L wrote: > > The page (https://golang.org/cmd/go/#hdr-Remote_import_paths) mentions > >> For example, >> >> import "example.org/pkg/foo" >> >> will result in the following requests: >> >> https://example.org/pkg/foo?go-get=1 (preferred) >> http://exa

Re: [go-nuts] aafaf

2019-03-11 Thread Ian Lance Taylor
g/x/text as the import-prefix, and it would double check that that import-prefix had the same meta tag. Ian > On Monday, March 11, 2019 at 7:50:43 PM UTC-4, Ian Lance Taylor wrote: >> >> On Mon, Mar 11, 2019 at 12:17 PM T L wrote: >> > >> > The page (https://golan

Re: [go-nuts] [CoC] screenshot images. Lazines or incompetence?

2019-03-12 Thread Ian Lance Taylor
On Tue, Mar 12, 2019 at 4:09 AM Wojciech S. Czarnecki wrote: > > And I petition for the go-nuts list introduction [1] to be explicit about > screenshot attachments and about using playground for longer > snippets of code. Thanks, I added a shorter version of that to the intro. I don't know how m

Re: [go-nuts] Order of evaluation need more definition in spec

2019-03-14 Thread Ian Lance Taylor
On Thu, Mar 14, 2019 at 2:49 PM zshi via golang-nuts wrote: > > I'm a little bit confused with result from below code: > > func change(v *int) bool { > *v = 3 > return true > } > > func value(v int) int { > return v > } > > func main() { > b := 1 > fmt.Println(b + 1, value(b +

Re: [go-nuts] net: should default DNS resolver try every server?

2019-03-15 Thread Ian Lance Taylor
On Fri, Mar 15, 2019 at 8:31 AM Timofei Bredov wrote: > > Context: I use go version go1.12 linux/amd64. I have a VPN set up which has > private DNS server. This server can resolve URLs that have top level domain > name ".custom-tld". > > File /etc/resolvconf has the following content: > > namese

Re: [go-nuts] Re: Go 1.12.1 and Go 1.11.6 are released

2019-03-17 Thread Ian Lance Taylor
On Sun, Mar 17, 2019 at 1:46 PM Serhat Şevki Dinçer wrote: > > I see a regression on speed with sorty tests (go test -short -gcflags '-B -s' > -ldflags '-s -w') on my Intel Core i5-4210M laptop (also sortutil became > faster, zermelo float became much slower): Please open an issue with full det

Re: [go-nuts] cgo:build trouble

2019-03-18 Thread Ian Lance Taylor
On Sun, Mar 17, 2019 at 9:37 PM wrote: > > package main > > import( > ) > > /* > #include > */ > import "C" > > func main() { > C.printf(C.CString("hello")) > } > > //>build this file with go build, i got > //./testems.go:12:2: unexpected type: ... > > could someone help me with this trouble?

Re: [go-nuts] Signal SIGSEGV: segmentation violation code=0x1

2019-03-18 Thread Ian Lance Taylor
On Mon, Mar 18, 2019 at 8:17 PM <615912...@qq.com> wrote: > > shmid, _, err := syscall.Syscall(syscall.SYS_SHMGET, uintptr(10001), 1<<32, > IpcCreate|0600) > data_shmaddr, _, _ := syscall.Syscall(syscall.SYS_SHMAT, shmid, 0, 0) > C.memcpy(unsafe.Pointer(data_shmaddr+uintptr(per_offs)), > unsafe.P

Re: [go-nuts] C# nameof equivalent

2019-03-19 Thread Ian Lance Taylor
On Tue, Mar 19, 2019 at 5:19 AM saurabh singh wrote: > > Is there an alternative for nameof in golang. > I don't want reflection magic. > Use case is to avoid log messages, validation etc to go out of sync with code > changes: > > func foo(correctParamName string) (interface{}, error){ > if

Re: [go-nuts] C# nameof equivalent

2019-03-19 Thread Ian Lance Taylor
ion (constant generation) not runtime. >> >> I’ve never used it but the ops request seems reasonable. >> >> Go 2.0 proposal I guess. >> >> > On Mar 19, 2019, at 7:53 AM, Ian Lance Taylor wrote: >> > >> >> On Tue, Mar 19, 2019 at 5:19 A

Re: [go-nuts] Go command support for "make"

2019-03-20 Thread Ian Lance Taylor
On Tue, Mar 19, 2019 at 10:05 PM Lucio wrote: > > I'm hoping this already has an answer, rather than require additional > features. I also don't expect this to be a popular request, but I do consider > its merits as greater than the disadvantages, so here goes. > > Efforts to eliminate the use o

Re: [go-nuts] Go command support for "make"

2019-03-20 Thread Ian Lance Taylor
On Wed, Mar 20, 2019 at 7:01 AM Paul Jolly wrote: > > > test $(go list -f '{{.Stale}}' internal/package$) = "true" > > Does .Stale still have meaning/is it still accurate in a build cache world? I doubt it, but I'm not sure the original question has any meaning in that world. In a build cache wo

Re: [go-nuts] Signal SIGSEGV: segmentation violation code=0x1

2019-03-21 Thread Ian Lance Taylor
ate a probability based on the insertion time of the data. The last > one has probability n/(1+2+...+n). > total := data_cnt * (data_cnt + 1) / 2 > random := rand.Intn(total) + 1 > data_i := 0 > for i := 1; i <= data_cnt; i++ { > a := i * (i - 1) / 2 > b := i * (i +

Re: [go-nuts] Do I need to use runtime.KeepAlive in this case?

2019-03-21 Thread Ian Lance Taylor
On Wed, Mar 20, 2019 at 10:56 PM Cholerae Hu wrote: > > package main > > // void a(long *p) {} > import "C" > > import ( > "unsafe" > ) > > //go:noinline > func b() { > x := int64(0) > C.a((*C.long)(unsafe.Pointer(&x))) > // do something without x > } > > func main() { > b() > } > > x should be co

Re: [go-nuts] Accessing *[]uint64 from assembly - strange memory corruption under heavy load - any ideas?

2019-03-21 Thread Ian Lance Taylor
On Thu, Mar 21, 2019 at 9:39 PM Tom wrote: > > I've been stuck on this for a few days so thought I would ask the brains > trust. > > TL;DR: When I have native amd64 instructions mutating (updating the len + > values of a []uint64) a slice, I experience spurious & random memory > corruption when

Re: [go-nuts] Re: Accessing *[]uint64 from assembly - strange memory corruption under heavy load - any ideas?

2019-03-22 Thread Ian Lance Taylor
On Fri, Mar 22, 2019 at 10:55 AM Robert Johnstone wrote: > > I don't see any memory barriers in your assembly. If you are modifying the > backing array while it is being scanned by the GC, there could be some > interaction. I don't know enough about the GC internals to say more than > that.

Re: [go-nuts] what +build flags do I need to distinguish between ios and macos please?

2019-03-22 Thread Ian Lance Taylor
On Fri, Mar 22, 2019 at 5:04 PM whitehexagon via golang-nuts wrote: > > I'm experimenting with some cross platform development in Go. btw loving the > WASM support! > > so for mac desktop I'm using // +build darwin,386 > for android I can see a GOOS android value, so I'm guessing +build > andro

Re: [go-nuts] rand.Rand.Seed() vs rand.NewSource()

2019-03-26 Thread Ian Lance Taylor
On Tue, Mar 26, 2019 at 11:48 AM Liam Breck wrote: > > Could anyone clarify the difference between these two? > > r := rand.New(rand.NewSource(...)) > > var r rand.Rand; r.Seed(...) Well, it's not a complete program, and maybe I'm missing something, but it seems to me that the difference is that

Re: [go-nuts] net.Conn types: File vs SyscallConn method

2019-03-26 Thread Ian Lance Taylor
On Mon, Mar 25, 2019 at 11:04 AM Matt Layher wrote: > > I've been doing low-level networking work in Go for a few years now, but I > had a realization the other day: > > With the addition of the SyscallConn method in Go 1.9 to several > net.Conn/PacketConn types, what is the advantage of using t

Re: [go-nuts] Re: rand.Rand.Seed() vs rand.NewSource()

2019-03-27 Thread Ian Lance Taylor
On Wed, Mar 27, 2019 at 9:16 AM wrote: > > Hi, > I think OP question actually is what is difference between: > r := rand.New(rand.NewSource(VALUE)) > > and > r := rand.New(rand.NewSource(ANYTHING)) > > r.Seed(VALUE) > > https://play.golang.org/p/afOfMjcNs1q I don't think there is any meaningful

Re: [go-nuts] Funny Minor Error Messsage Grammar Problem

2019-03-27 Thread Ian Lance Taylor
On Wed, Mar 27, 2019 at 6:06 PM wrote: > > $ go build a.go > # command-line-arguments > ./a.go:16:12: assignment mismatch: 2 variable but 1 values > > Note the English syntax problem in the (correct) error message. > It should be > > ./a.go:16:12: assignment mismatch: 2 variables but 1 value Than

Re: [go-nuts] [URGENT] Pass array of string between Go and C library

2019-03-28 Thread Ian Lance Taylor
On Thu, Mar 28, 2019 at 3:08 PM Ashutosh Baghel wrote: > > Hi folks, > > I am new to Go-Programming and having the following requirement, I need to > have Array of Strings,(for example names) at my 'Go Side' . > > But i would get this names from my C library API which i have included in my > Go

Re: [go-nuts] go: Passing a member function as an argument compile error

2019-03-28 Thread Ian Lance Taylor
On Thu, Mar 28, 2019 at 9:42 PM Greg Bostrom wrote: > > I just posted this on on openstack. > Maybe someone here knows the answer? > > https://stackoverflow.com/questions/55410250/go-passing-a-member-function-as-an-argument-compile-error > > I would expect this to compile after watching this talk

Re: [go-nuts] go: Passing a member function as an argument compile error

2019-03-28 Thread Ian Lance Taylor
On Thu, Mar 28, 2019 at 10:02 PM Greg Bostrom wrote: > > No, I intended to call New(foo) Well, in the program you showed us, foo is not defined, and that is what the compiler is telling you. It was mistaken in thinking that you meant new(M), though, since you actually want to call New. What you

Re: [go-nuts] Re: proposal: Go 2: add untyped() type conversion for integer constants #31076

2019-03-29 Thread Ian Lance Taylor
On Thu, Mar 28, 2019 at 11:17 PM Jan Mercl <0xj...@gmail.com> wrote: > > The Compatibility section of the proposal says: "I think that this would > break no existing code, as a user function invocation untyped(EXPR) is not at > present allowed in constant specifications." > > It's true that user

Re: [go-nuts] What do the U, V, and W in function names in src/math/big stand for?

2019-03-29 Thread Ian Lance Taylor
On Fri, Mar 29, 2019 at 3:14 PM Neven Sajko wrote: > > For example in mulWW or addVV? It seems to maybe have something to do > with function arguments? W is a word (Word aka uint), V is a slice of word ([]Word). U is also a slice of word, but I'm not sure what the difference between V and U is.

Re: [go-nuts] Looking for help in debugging CGO failures

2019-04-01 Thread Ian Lance Taylor
On Mon, Apr 1, 2019 at 7:05 PM Charles wrote: > > We're developing a Go wrapper for a C library/database (YottaDB), and use the > CGO interface to call YottaDB C API functions. We're encountering a variety > of failure symptoms about 1% of the time in our test system; some errors we > get inclu

Re: [go-nuts] Where can I find the Golang spec source code?

2019-04-02 Thread Ian Lance Taylor
On Tue, Apr 2, 2019 at 8:22 PM 李健 wrote: > > The web page is at: https://golang.org/ref/spec > > I've searched Google/GitHub but can't find its source code, something > like `golang_spec.md`. > > In golang/go GitHub repo, I found a file named > `go_spec.html`(https://github.com/golang/go/blob/mast

Re: [go-nuts] A value copy will occur when executing for range xxx?

2019-04-03 Thread Ian Lance Taylor
On Wed, Apr 3, 2019 at 6:32 AM wrote: > > thanks! v must be a value copy,Is this determined by the compiler? It's determined by the language definition. Ian > 在 2019年4月3日星期三 UTC+8下午7:57:26,Marvin Renich写道: >> >> * mount...@gmail.com [190403 05:10]: >> > package main >> > >> > func main() { >>

Re: [go-nuts] source for scheduler and gc?

2019-04-03 Thread Ian Lance Taylor
On Wed, Apr 3, 2019 at 8:34 AM Jason E. Aten wrote: > > Where does the source for the runtime scheduler and garbage collector live > these days? The central locations are runtime/proc.go and runtime/mgc.go. > Wherefore, I need to locate all runtime background threads and add in a means > to s

Re: [go-nuts] How to link different static libararies on different platforms?

2019-04-03 Thread Ian Lance Taylor
On Wed, Apr 3, 2019 at 8:30 AM T L wrote: > > Assume I have a .go soruce file like: > > /* > #cgo LDFLAGS: -L${SRCDIR}/lib/static/linux/amd64 -lmylib > ... // more flags > */ > import "C" > > ... // many cross-platform Go code lines > > > Now, It compiles ok on Linux AMD64 platform. > > There are

Re: [go-nuts] how golang creates binary

2019-04-03 Thread Ian Lance Taylor
On Wed, Apr 3, 2019 at 12:27 PM wrote: > > Hi, > Any one explain the background process of go build or how go build creates > shared objects and include into go binary. > Here sharing my experience with c shared files. > Earlier I worked with there we creating some shared objects of my projects

Re: [go-nuts] A value copy will occur when executing for range xxx?

2019-04-04 Thread Ian Lance Taylor
On Wed, Apr 3, 2019 at 11:50 PM wrote: > > hehe, thanks, so if i want understand deeply, need to look up gc code? No, the language spec is at https://golang.org/ref/spec. Ian > 在 2019年4月3日星期三 UTC+8下午10:34:57,Ian Lance Taylor写道: >> >> On Wed, Apr 3, 2019 at 6:32 AM wrote

Re: [go-nuts] runtime.pclntab strippping

2019-04-04 Thread Ian Lance Taylor
On Thu, Apr 4, 2019 at 2:32 PM Steeve Morin wrote: > > We are big Go users on Android and iOS thanks to golang/mobile. > > Lately we were doing some size profiling and stumbled upon runtime.pclntab, > which in our case represents almost 20% of the file size according to bloaty. > Now I understand

Re: [go-nuts] runtime.pclntab strippping

2019-04-05 Thread Ian Lance Taylor
#x27;m not promising that such a linker option would be accepted into the main tree.) > I would assume most of that happens in cmd/link/internal/ld/pcln.go right ? As far as I know, yes. Ian > On Friday, April 5, 2019 at 12:14:49 AM UTC+2, Ian Lance Taylor wrote: >> >> On Thu, Apr

Re: [go-nuts] Confusion regarding templates and iterating over map

2019-04-07 Thread Ian Lance Taylor
On Sun, Apr 7, 2019 at 6:19 PM Amit Saha wrote: > > I am seeing (what I think) a somewhat confusing behavior which I am not sure > I understand. The working code example is at > https://play.golang.org/p/GEqT4MiZQnq > > > Basically, I have a map which I am iterating over in a template: > > > m :

Re: [go-nuts] Modifying the Runtime Scheduler

2019-04-08 Thread Ian Lance Taylor
On Sun, Apr 7, 2019 at 12:30 PM Tharen Abela wrote: > > The gist of the problem is that I am allocating an object in the runtime, > (which I refer to as the batch struct), and the GC is deallocating the > object, even though a reference is being kept in a slice (similar to allp and > allm). > W

Re: [go-nuts] Why will it deadlock if a goroutine acquire a mutex while pinned to its P?

2019-04-08 Thread Ian Lance Taylor
[ + austin ] On Sun, Apr 7, 2019 at 11:31 PM Cholerae Hu wrote: > > I'm reading this commit > https://github.com/golang/go/commit/d5fd2dd6a17a816b7dfd99d4df70a85f1bf0de31 > . Inside runtime_procPin we only increases the m.lock count, why will it > cause deadlock when acquiring a mutex after p

Re: [go-nuts] linker panics on ld.decodetypeKind

2019-04-08 Thread Ian Lance Taylor
On Mon, Apr 8, 2019 at 8:52 PM wrote: > > I build .debs of Go which are used as a dependency for Prometheus debs. > Doing code upgrades I started getting a weird panic from the Go linker that I > don't see elsewhere on the Internet, and seems different from the cgo bug > that caused 1.12.3 to

Re: [go-nuts] gcwaiting=1 will causes block all the goroutines?

2019-04-10 Thread Ian Lance Taylor
On Wed, Apr 10, 2019 at 4:52 AM wrote: > > My macos has 4 cores, but i start 3 goroutines, 2 sub goroutines, 1 main > goroutine. > After main goroutine exec 3 times output, triggering gc causes gcwaiting=1. > Finally all goroutine blocking > > package main > > import ( > "fmt" > "log" > "net/h

Re: [go-nuts] Access to variable names on goroutine stacks and on the heap in the runtime

2019-04-10 Thread Ian Lance Taylor
On Tue, Apr 9, 2019 at 7:43 AM wrote: > > I have been working on a research project where I have been modifying the > runtime such that I can control the goroutines that are scheduled as well as > get access to the values of program variables. > I know I can access the stack through the g struct

Re: [go-nuts] Access to variable names on goroutine stacks and on the heap in the runtime

2019-04-10 Thread Ian Lance Taylor
ril 2019 13:28:49 UTC-7, Ian Lance Taylor wrote: >> >> On Tue, Apr 9, 2019 at 7:43 AM wrote: >> > >> > I have been working on a research project where I have been modifying the >> > runtime such that I can control the goroutines that are scheduled as well >&

Re: [go-nuts] Access to variable names on goroutine stacks and on the heap in the runtime

2019-04-10 Thread Ian Lance Taylor
On Wed, Apr 10, 2019 at 5:27 PM vaastav anand wrote: > > > That is the bare bones of the DWARF information. That will let you > read the DWARF info, but it won't help you map PC and SP values to > variable names. > > I am not sure why this is the case. I thought along with the dwarf info, once >

Re: [go-nuts] Re: Learning Data Structures and algorithms with Golang

2019-04-12 Thread Ian Lance Taylor
On Fri, Apr 12, 2019 at 3:55 PM wrote: > > Bhagvan's disgrceful misuse of this forum to support his commercial endeavors > should result in the exclusion of all his future posts Thanks for the note. I encourage you to be respectful, as discussed at the Gopher Code of Conduct that governs this

[go-nuts] Re: Language Specification nit under Constant declarations

2019-04-15 Thread Ian Lance Taylor
[ +gri ] On Mon, Apr 15, 2019 at 9:27 AM Marvin Renich wrote: > > At https://golang.org/ref/spec#Constant_declarations where it talks > about omitting the expression list, it says > > Such an empty list is equivalent to the textual substitution of the > first preceding non-empty expression li

Re: [go-nuts] Current Thinking on Explicit Memory Freeing?

2019-04-16 Thread Ian Lance Taylor
On Tue, Apr 16, 2019 at 8:46 PM wrote: > > Go's garbage collector is very nice, and solves many problems that come up in > C programs. > > However, one thing I've been wondering about is explicitly freeing memory. I > know it can't be done > now, and that the GC takes care of everything. > > But

Re: [go-nuts] Current Thinking on Explicit Memory Freeing?

2019-04-16 Thread Ian Lance Taylor
On Tue, Apr 16, 2019 at 9:48 PM Robert Engels wrote: > > I think the OP was implying that GC is inefficient and was inquiring about > certain patterns of memory use could be freed more efficiently. I see. I wouldn't worry about it, at least not without clear evidence of some problem. The cost

Re: [go-nuts] Re: fatal error: 'config.h' file not found

2019-04-16 Thread Ian Lance Taylor
On Tue, Apr 16, 2019 at 9:56 PM Nitish Saboo wrote: > > I am new to GO.Can I get little help on this ? It's really hard to know what the answer is. One thing you can try is adding a #cgo CFLAGS line with a -I option pointing to your syslog-ng directory. See https://golang.org/cmd/cgo. Ian >

Re: [go-nuts] Current Thinking on Explicit Memory Freeing?

2019-04-16 Thread Ian Lance Taylor
On Tue, Apr 16, 2019 at 9:53 PM wrote: > > In a compiler, say during the lexing and parsing phases, memory might be > allocated > that won't be needed after those phases are complete. The memory is still > referenced, > so the GC won't free it, but conceptually it actually could be freed. In >

Re: [go-nuts] Re: fatal error: 'config.h' file not found

2019-04-17 Thread Ian Lance Taylor
On Wed, Apr 17, 2019 at 4:59 AM Nitish Saboo wrote: > > Made recommended changes to the file main.go.You can see the file in my > repository : https://github.com/nitishsaboo/Testing > > Now 'go build -x' is failing with the following error: > > WORK=/tmp/go-build838755651 > mkdir -p $WORK/b001/ >

Re: [go-nuts] Re: methods on C types

2019-04-18 Thread Ian Lance Taylor
On Thu, Apr 18, 2019 at 9:17 AM Jan Mercl <0xj...@gmail.com> wrote: > > On Thu, Apr 18, 2019 at 6:07 PM Jamil Djadala wrote: > > > > On Thu, 18 Apr 2019 07:44:53 -0700 (PDT) > > peterGo wrote: > > > > > Cgo translates C types into equivalent unexported Go types. > > > https://golang.org/cmd/cgo/

Re: [go-nuts] Re: methods on C types

2019-04-18 Thread Ian Lance Taylor
On Thu, Apr 18, 2019 at 7:19 PM Jamil Djadala wrote: > > On Thu, 18 Apr 2019 11:34:25 -0700 > Ian Lance Taylor wrote: > > > That said, I have to agree that defining methods on types defined by > > cgo is never necessary and can only cause confusion. And cgo could >

Re: [go-nuts] binary.Read cgo fields

2019-04-21 Thread Ian Lance Taylor
On Sat, Apr 20, 2019 at 11:53 AM wrote: > > binary.Read can't set unexported fields, right? > But my structs are defined in C, and I can't make all C source code using > capital fields.. > What could I do? Read the fields separately. That is often a better idea in any case, as the result is mor

Re: [go-nuts] go build *.exe file size seems much too large

2019-04-21 Thread Ian Lance Taylor
On Sun, Apr 21, 2019 at 7:16 PM wrote: > > For this simple go code, the *.exe file size is 1800 KB ...why so large > compared to equivalent C-compiled code ?? > package main > import( "math"; "fmt" ) > func main() { > fmt.Printf("\n %8.3f", math.Sin(1.2) ) > } > Does the go generated *.exe file c

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Ian Lance Taylor
The lack of the ?: operator in Go is a FAQ: https://golang.org/doc/faq#Does_Go_have_a_ternary_form . 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-n

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Ian Lance Taylor
On Wed, Apr 24, 2019 at 1:14 PM andrey mirtchovski wrote: > > Here's the lore associated with the subject: Ken wanted ternary, Rob > and Robert did not. They overruled Ken (remember, early on all three > had to agree for a feature to go in). The end. I may easily misremember, but that doesn't mat

Re: [go-nuts] Error: opcode not supported on this processor: mips32

2017-07-22 Thread Ian Lance Taylor
On Sat, Jul 22, 2017 at 4:41 AM, Sander van Harmelen wrote: > Thanks Ian! And sorry for my late response… Didn’t find time the last few > days to test this. I use a different toolchain () and now I seem to get past > this problem :) > > But now I end up getting these errors: > > > /var/folders/2k

Re: [go-nuts] Error: Time function with non-usual compositions

2017-07-22 Thread Ian Lance Taylor
On Sat, Jul 22, 2017 at 5:54 AM, SerginRamos wrote: > > When reading the Time.go function, I found this non-usual code: > > Time.go: Line: 116-124 > > // String returns the English name of the month ("January", "February", > ...). > func (m Month) String() string { > if January <= m && m <= Decemb

Re: [go-nuts] Detecting promoted methods

2017-07-25 Thread Ian Lance Taylor
On Tue, Jul 25, 2017 at 9:04 AM, nz wrote: > > Using reflection I would like to be able to determine if a method has been > promoted (my use case is detecting if a method is overridden). But there > seems to be no way to detect a promoted method. When I use reflect.Method on > the structs I get tw

Re: [go-nuts] How to break a long code into lines in Golang?

2017-07-25 Thread Ian Lance Taylor
On Tue, Jul 25, 2017 at 4:38 PM, yihao yang wrote: > > I have some problems on break long code into lines when developing in > golang. > Could you please help me on how to break a long code as following? > time.Sleep(time.Duration(*Int64Flag_xxIntervalMS) * > time.Millisecond - time.No

Re: [go-nuts] Error: opcode not supported on this processor: mips32

2017-07-25 Thread Ian Lance Taylor
On Sat, Jul 22, 2017 at 12:57 PM, Sander van Harmelen wrote: > > Ok, I managed to get it compiled by first cross compiling libusb and then > pointing to it using the linker flags you suggested. So thank you very much, > I can now compile a binary that works on the target device :) > > I do have

Re: [go-nuts] Is there some way to set value for unexported nil ptr field of a struct using reflect?

2017-07-25 Thread Ian Lance Taylor
On Sun, Jul 23, 2017 at 12:46 AM, feilengcui008 wrote: > Hi, all: > I'm writing a little fuzz tool for struct using reflect package, and > came across the following case, but didn't find any way to solve it > > > type TestStruct struct { > a *int // unexported nil ptr field, how to

Re: [go-nuts] In memory compilation and execution of Go code

2017-07-26 Thread Ian Lance Taylor
On Tue, Jul 25, 2017 at 9:53 PM, Cristian Adamo wrote: > > I'm looking for a way to compile an in memory go file and execute it within > a go program.I have been looking around the go source code and found that > perhaps something from the cmd/go/internal package could be used to do such > task.

Re: [go-nuts] Details on the implementation decision for sync.Map

2017-07-26 Thread Ian Lance Taylor
On Wed, Jul 26, 2017 at 1:07 PM, Florin Pățan wrote: > > I would like to understand a bit better one particular implementation > decision regarding the new sync.Map feature. > > Besides having to introduce a new keyword to the language and some compiler > work, what were the other issues that push

Re: [go-nuts] Re: No Allman-Style, No go!

2017-07-27 Thread Ian Lance Taylor
On Thu, Jul 27, 2017 at 6:35 PM, Hrobjartur Thorsteinsson wrote: > > Do you realize that the Go lang devs themselves are not actually in > agreement about the original motivations for constraining the language in > this way. Some quote some one true K&R style, while it is in fact this is > not K&R

Re: [go-nuts] Movable pointees inquiry

2017-07-29 Thread Ian Lance Taylor
On Sat, Jul 29, 2017 at 3:20 AM, Jan Mercl <0xj...@gmail.com> wrote: > > I would like to ask for confirmation if I understand correctly few items. > Thank in advance for the answer(s). > > Bellow let's consider only correct, valid, race-free "normal" programs that > do not use CGO or directly call

Re: [go-nuts] Re: No Allman-Style, No go!

2017-07-30 Thread Ian Lance Taylor
On Sat, Jul 29, 2017 at 10:36 AM, wrote: > > ... > > But as Gofmt can ALREADY enforces this common coding style, and can be run > at any time, including before committing code on the depots, why should it > be enforced by the COMPILER too ? > > Really, that's the one particular engineer decision

Re: [go-nuts] Go goes crazy on math.Sin()

2017-07-30 Thread Ian Lance Taylor
On Sun, Jul 30, 2017 at 10:40 AM, wrote: > > I just ran this code on my pc: > > package main > > import ( >"fmt" >"math" > ) > > func main() { >const ali = 4e20 >fmt.Println(math.Sin(ali)) > } > > > and got this result: > > 1.3471173831553043e+258 > > Why Sin result goes more than

Re: [go-nuts] Re: No Allman-Style, No go!

2017-07-31 Thread Ian Lance Taylor
On Mon, Jul 31, 2017 at 10:10 AM, Hrobjartur Thorsteinsson wrote: > Hi Mr. Bushnell, > The code block identifier, in Go are { }. They are already part of the > syntax if I'm not mistaken. > Go proudly aiming to be a simplifying, lowest common denominator language > makes sense to me. > In that s

Re: [go-nuts] Is x/exp/shiny dead?

2017-07-31 Thread Ian Lance Taylor
[ +nigeltao ] On Mon, Jul 31, 2017 at 1:25 PM, fazal wrote: > It was one of the things I was looking forward to, but I see almost no > activity there, which makes me sad. > > Is it because it is mature enough for general use? There is a road-map for > widgets but non are complete. I really hope i

<    1   2   3   4   5   6   7   8   9   10   >