Re: [go-nuts] \n new line feed

2018-12-10 Thread Ian Lance Taylor
On Sun, Dec 9, 2018 at 10:19 AM 伊藤和也 wrote: > > In fmt.Println function, \n is used. Is \n safe to use in different platforms? Yes. 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 fr

Re: [go-nuts] Forking/transfering a repository and import paths

2018-12-12 Thread Ian Lance Taylor
On Wed, Dec 12, 2018 at 8:08 AM Robert Engels wrote: > > I am pretty sure that the correct solution is to decouple the package from > its location. And a global Go registry can tell Go get where that package can > currently be found. You don't need a global registry. Or, rather, the global reg

Re: [go-nuts] Go offline development recommendations

2018-12-13 Thread Ian Lance Taylor
On Thu, Dec 13, 2018 at 4:00 AM akshita babel wrote: > > Hey, can anyone guide me on how to take octet stream as input in API and/or > how to convert octet stream to byte array using golang If you want to ask an unrelated question, please send a new message, rather than replying to an existing t

Re: [go-nuts] Homoiconic metaprogramming in Go

2018-12-13 Thread Ian Lance Taylor
On Thu, Dec 13, 2018 at 9:25 PM Dmitry Ponyatov wrote: > > Is it possible to do metaprogramming in Go? > > What I want to have is a way to run arbitrary code in compile time, which has > full access to compiler data structures > (parsed syntax trees, compiler stages callbacks, direct code generat

Re: [go-nuts] Zombie Child process not being claimed by wait

2018-12-13 Thread Ian Lance Taylor
On Thu, Dec 13, 2018 at 9:33 PM wrote: > > I'm debugging an odd issue with Process.Wait, and wondering if anyone would > have any ideas / hit this before: > > I have a go process, which starts a child process (it sets DEATH_SIGNAL on > that process, not sure if it's relevant). > Then, a backgrou

Re: [go-nuts] symbol lookup error: /root/llvm-install/lib64/libgo.so.8svn: undefined symbol: __get_cpuid_count after "make install"

2018-12-16 Thread Ian Lance Taylor
[ + thanm ] On Sat, Dec 15, 2018 at 6:56 AM wrote: > > I'm trying to use the current gollvm build, but it seems there is a symbol > error. Probably that symbol is absent in the libgo release? > Anyone had a similar problem or an idea how I can fix that? The libgo sources expect __get_cpuid_coun

Re: [go-nuts] Constants

2018-12-16 Thread Ian Lance Taylor
On Sun, Dec 16, 2018 at 6:15 PM 伊藤和也 wrote: > > Can I say the type of the integer constant "12" is converted from the default > type "int" to "int32" when it is assigned to the constant "n1" whose type is > "int32" ? > > const n1 int32 = 12 > > Go programmimg language specification says "An unt

Re: [go-nuts] Declaration of interfaces

2018-12-17 Thread Ian Lance Taylor
On Mon, Dec 17, 2018 at 3:08 PM Victor Giordano wrote: > > This is not legal statement right? > > > var a interface{id int} // let's call it "anonymous interface" > > > if we employ 'interface{}' to refer to empty interfaces it may has sense to > think the above declaration as an "anonymous inte

Re: [go-nuts] Channels: selecting the last element

2018-12-18 Thread Ian Lance Taylor
On Tue, Dec 18, 2018 at 5:35 AM Chris Burkert wrote: > > I have a couple of goroutines sending multiple results over a channel - a > simple fan-in. They signal the completion on a done channel. Main selects on > the results and done channel in parallel. As the select is random main > sometimes

Re: [go-nuts] symbol lookup error: /root/llvm-install/lib64/libgo.so.8svn: undefined symbol: __get_cpuid_count after "make install"

2018-12-18 Thread Ian Lance Taylor
definition of , but they don't define >>>> __get_cpuid_count -- that seems to have been added later in this commit. >>>> >>>> Do you have a later version of clang that you could use as your build >>>> compiler (5.0 later)? Or could you use GCC instea

Re: [go-nuts] Returning pointer to struct from cgo to C cause panic: runtime error: cgo result has Go pointer

2018-12-18 Thread Ian Lance Taylor
On Tue, Dec 18, 2018 at 6:27 AM wrote: > > I have to projects. One is cgo and one is C application. > The cgo has a function which needs to return pointer to struct. > The C app receives this pointer and then calls other function in cgo with > this pointer. > I build the cgo as shared lib: > > go

Re: [go-nuts] Language line in go.mod

2018-12-18 Thread Ian Lance Taylor
On Tue, Dec 18, 2018 at 8:07 AM Sam Whited wrote: > > I've been asked multiple times recently to point people to documentation for > the language line in a go.mod file (eg. the `go 1.12' line that's added by > recent builds), but I haven't been able to find any on the wiki or in `go > help modu

Re: [go-nuts] Are there typed variables?

2018-12-18 Thread Ian Lance Taylor
On Tue, Dec 18, 2018 at 6:25 PM Yanhao Mo wrote: > > 伊藤和也 writes: > > > Are there typed variables? > I'm affraid not. I'm not sure what any of this really means, but, to be clear, in Go all variables have types. Ian -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] Language line in go.mod

2018-12-18 Thread Ian Lance Taylor
On Tue, Dec 18, 2018 at 7:44 PM komuW wrote: > > is go.sum documented? I have seen a couple of questions on the same in the > #modules channel on gophers slack go.sum is documented, briefly, at https://tip.golang.org/cmd/go/#hdr-Module_downloading_and_verification. I don't know whether it deserv

Re: [go-nuts] Possibly broken go compiler (specific situation inside)

2018-12-19 Thread Ian Lance Taylor
On Wed, Dec 19, 2018 at 7:37 AM Miroslav Němec wrote: > > I have an example of uncompilable code here - > https://play.golang.org/p/yIYEa1YcQfs , compiler wrongly identifies type of > A.c . > > I can go around the issue when I move newA function below type definitions > https://play.golang.org/

Re: [go-nuts] Go 1.12 Beta 1 is released

2018-12-19 Thread Ian Lance Taylor
On Tue, Dec 18, 2018 at 10:07 PM Peter Kleiweg wrote: > > Go 1.12 is the last release that will support binary-only packages. > > What are the alternatives? > > I need binary-only packages for packages that use cgo with non-standard > environment variable values. You can compile your C code into

Re: [go-nuts] Go 1.12 Beta 1 is released

2018-12-19 Thread Ian Lance Taylor
On Wed, Dec 19, 2018 at 10:50 AM Peter Kleiweg wrote: > > How do I do what runtime/race does? Is it what I want? > > I have a package with C and Go files. I want to install that package. Then I > want to import that package into a program, and build that program without > recompiling the package

Re: [go-nuts] Possibly broken go compiler (specific situation inside)

2018-12-19 Thread Ian Lance Taylor
On Wed, Dec 19, 2018 at 7:46 AM Ian Lance Taylor wrote: > > On Wed, Dec 19, 2018 at 7:37 AM Miroslav Němec wrote: > > > > I have an example of uncompilable code here - > > https://play.golang.org/p/yIYEa1YcQfs , compiler wrongly identifies type of > > A.c . >

Re: [go-nuts] if/switch statements as expressions

2018-12-19 Thread Ian Lance Taylor
On Wed, Dec 19, 2018 at 12:09 PM Viktor Kojouharov wrote: > > I've tried and failed at finding any previous discussion on this topic, so do > point me to one if it exists. > > I'm interested to know whether it was considered (I can't imagine that it > wasn't) for if and switch statements to be e

Re: [go-nuts] performance optimization

2018-12-19 Thread Ian Lance Taylor
On Wed, Dec 19, 2018 at 1:29 PM Tamás Király wrote: > > my task is to update a value every microsecond. > i did an it with an infinite loop with time.Sleep like this > > https://play.golang.org/p/JiN3_5KiGOO > > this causes me about 50-60% of CPU usage on my machine but i made another > version w

Re: [go-nuts] Go 1.12 Beta 1 is released

2018-12-19 Thread Ian Lance Taylor
On Wed, Dec 19, 2018 at 2:15 PM Peter Kleiweg wrote: > > > I assume that the recompile fails because compiling the C code fails. > You should compile the C code yourself, producing a .syso file. You > should add that .syso file to your package directory. You should > remove the C code from your

Re: [go-nuts] Go 1.12 Beta 1 is released

2018-12-19 Thread Ian Lance Taylor
On Wed, Dec 19, 2018 at 2:55 PM Peter Kleiweg wrote: > > Ian Lance Taylor schreef op 19 december 2018 23:27:13 CET: > > On Wed, Dec 19, 2018 at 2:15 PM Peter Kleiweg > > wrote: > > > > > > > I assume that the recompile fails because compiling the C code &g

Re: [go-nuts] Re: performance optimization

2018-12-19 Thread Ian Lance Taylor
On Wed, Dec 19, 2018 at 6:52 PM robert engels wrote: > > I don’t think the analysis is correct in the issue cited. No one mentions > just using usleep() as the system call like a C program would, at least for > time.Sleep(), and block the calling thread. That doesn't scale to large numbers of g

Re: [go-nuts] Go 1.12 Beta 1 is released

2018-12-20 Thread Ian Lance Taylor
On Thu, Dec 20, 2018 at 1:07 AM Peter Kleiweg wrote: > > Ian Lance Taylor schreef op 20 december 2018 00:06:58 CET: > > > How about this: > > > > Move the C files to a subdirectory. Write a script or Makefile that > > compiles the C files into a .syso f

Re: [go-nuts] Go 1.12 Beta 1 is released

2018-12-20 Thread Ian Lance Taylor
On Thu, Dec 20, 2018 at 8:02 AM Peter Kleiweg wrote: > > Ian Lance Taylor schreef op 20 december 2018 16:47:20 CET: > > On Thu, Dec 20, 2018 at 1:07 AM Peter Kleiweg > > wrote: > > > > > > Ian Lance Taylor schreef op 20 december 2018 > >

Re: [go-nuts] Go 1.12 Beta 1 is released

2018-12-20 Thread Ian Lance Taylor
On Thu, Dec 20, 2018 at 10:58 AM Peter Kleiweg wrote: > > Ian Lance Taylor schreef op 20 december 2018 19:20:13 CET: > > On Thu, Dec 20, 2018 at 8:02 AM Peter Kleiweg > > wrote: > > > > > > Ian Lance Taylor schreef op 20 december 2018 > > 16:47:20 CE

Re: [go-nuts] Re: go1.12 memory release on Linux

2018-12-20 Thread Ian Lance Taylor
On Thu, Dec 20, 2018 at 2:13 PM wrote: > > The wording is kinda bad. All it means is that the runtime was updated to use > MADV_FREE instead of MADV_DONTNEED if possible. > > You can read about the difference on the madvise(2) man page, but basically > MADV_FREE is more lazy. There is no actual

Re: [go-nuts] Go 1.12 Beta 1 is released

2018-12-20 Thread Ian Lance Taylor
On Thu, Dec 20, 2018 at 2:32 PM Peter Kleiweg wrote: > > Ian Lance Taylor schreef op 20 december 2018 23:10:17 CET: > > On Thu, Dec 20, 2018 at 10:58 AM Peter Kleiweg > > wrote: > > > > > > Ian Lance Taylor schreef op 20 december 2018 > > 19:20:13 C

Re: [go-nuts] Re: go1.12 memory release on Linux

2018-12-20 Thread Ian Lance Taylor
On Thu, Dec 20, 2018 at 2:35 PM aaronb via golang-nuts wrote: > > Thanks for the clarification. The system I am testing on is swapless, so > maybe would explain why RSS is not increasing. >> >> On a swapless system, freeing pages in a given range happens instantly, >> regardless of memory pressu

Re: [go-nuts] reflect Kind method

2018-12-24 Thread Ian Lance Taylor
On Mon, Dec 24, 2018 at 9:29 AM Mark Volkmann wrote: > > IIUC, Kind is a method of both Type and Value. But the index near the top of > https://golang.org/pkg/reflect/ only shows it as a method of Value. If you > click on "type Type" in the index, it scrolls to the description of that > interfa

Re: [go-nuts] reflect Kind method

2018-12-24 Thread Ian Lance Taylor
hods of an interface, it will link to the definition of the interface. If we list the fields of a struct, it will link to the definition of the struct. That doesn't seem helpful. Ian > On Mon, Dec 24, 2018 at 12:04 PM Ian Lance Taylor wrote: >> >> On Mon, Dec 24, 2018 at 9:29

Re: [go-nuts] why in source of go compiler, initialize a *gc.Node with the help of a temp struct x? can't we initialize it directly?

2018-12-25 Thread Ian Lance Taylor
On Tue, Dec 25, 2018 at 10:13 PM wrote: > > I notice in the source comiler go initialize a Node n use a temp x, why the > variable n is initialized like this? > > why just initilize the n like below? > n = new(Node) > n.Func = new(Func) > > > > the source from File: src/cmd/compile/internal/gc/su

Re: [go-nuts] Number threads run by a simple golang application

2018-12-26 Thread Ian Lance Taylor
On Wed, Dec 26, 2018 at 8:49 AM wrote: > > I'm trying to understand more about the threads running in a golang > application. > I ran the following endless loop > > package main > > import ( > "fmt" > "os" > ) > > func main() { > fmt.Println("main running ",os.Getpid()) > for{} >

Re: [go-nuts] cgo with custom toolchain

2018-12-30 Thread Ian Lance Taylor
On Sat, Dec 29, 2018 at 11:23 PM wrote: > > Any example on how I can build cgo code using custom toolchain? I'm not sure what you are asking. Even with a custom toolchain, can't you just `go build`? If you need to run cgo directly, there are some brief docs for that at the bottom of https://gol

Re: [go-nuts] Type inference in non-constant shift expressions

2018-12-30 Thread Ian Lance Taylor
On Sat, Dec 29, 2018 at 11:12 PM Caleb Spare wrote: > > I noticed the following: > > package main > > func main() { > x := float64(1 << 3) // fine (constant expression) > > v := uint(3) > x = float64(1 << v) // invalid operation: 1 << uint(v) (shift of type float64) > > _ = x > } > > (playground:

Re: [go-nuts] What are the reasonable reasons to use pointers?

2019-01-01 Thread Ian Lance Taylor
On Tue, Jan 1, 2019 at 6:42 PM Bakul Shah wrote: > > On Tue, 01 Jan 2019 03:34:34 -0800 =?UTF-8?B?5LyK6Jek5ZKM5Lmf?= > wrote: > > > > What are the reasonable reasons to use pointers? Are pointers neseccary? > > Pointers are not necessary as a programming language feature > but are necessary in i

Re: [go-nuts] C++ 11 to Golang convertor

2019-01-02 Thread Ian Lance Taylor
On Wed, Jan 2, 2019 at 7:37 PM wrote: > > I have C++ 11 source files which I need to convert to Go language code > Is there any converter tool for this. > I google quite a few tools, none seems powerful and complete enough to do the > job.for me. C++ 11 is a much more complex language than Go.

Re: [go-nuts] Can I say a stack overflow is a panic?

2019-01-04 Thread Ian Lance Taylor
On Fri, Jan 4, 2019 at 8:31 AM Kevin Conway wrote: > > There are several conditions that bypass recover. Another example is "fatal > error: concurrent map read and map write". The error messages typically start > with "fatal error" and represent a non recoverable exception in the run time > rat

Re: [go-nuts] Re: C++ 11 to Golang convertor

2019-01-04 Thread Ian Lance Taylor
On Fri, Jan 4, 2019 at 8:52 AM wrote: > > On Thursday, January 3, 2019 at 5:46:39 PM UTC-5, Eric Raymond wrote: >> >> On Thursday, January 3, 2019 at 12:11:06 PM UTC-5, Jake Montgomery wrote: >>> >>> I would note that any tool that ports from C++, or even C, to Go is going >>> to produce ugly, un

Re: [go-nuts] gotcha: don't take the address of a for-range loop variable

2019-01-06 Thread Ian Lance Taylor
On Sun, Jan 6, 2019 at 10:38 PM wrote: > > https://play.golang.org/p/NnACN5fLPT3 > > I was taking the address of the for-loop variable ("&v" in the example above) > and was surprised to find that all my items pointed the same address. I > thought I had found most of the Golang gotchas by now, bu

Re: [go-nuts] Go 1.12 Beta 1 is released

2019-01-07 Thread Ian Lance Taylor
On Mon, Jan 7, 2019 at 1:33 AM Jan Mercl <0xj...@gmail.com> wrote: > > On Wed, Dec 19, 2018 at 1:27 AM Filippo Valsorda wrote: > > > > We have just released go1.12beta1, a beta version of Go 1.12. > > It is cut from the master branch at the revision tagged go1.12beta1. > ... > > Report any problem

Re: [go-nuts] Q: Moveable stacks and runtime.LockOSThread

2019-01-08 Thread Ian Lance Taylor
On Tue, Jan 8, 2019 at 4:56 AM Jan Mercl <0xj...@gmail.com> wrote: > > When an ordinary goroutine (not a CGo call into C) executes > runtime.LockOSThread, does its stack become the OS thread stack? In > particular, I'm interested if that guarantees fixed (pinned) pointers > pointing into the sta

Re: [go-nuts] Code coverage for a project

2019-01-09 Thread Ian Lance Taylor
On Tue, Jan 8, 2019 at 11:52 PM wrote: > > I have creates all my test files in a separate single folder. Is it possible > to get code coverage as the source files are in different location not with > test files. > I am getting code coverage report with coverprofile when test files and > source

Re: [go-nuts] Can I say that a pointer is a reference or memory address to a value?

2019-01-09 Thread Ian Lance Taylor
On Tue, Jan 8, 2019 at 9:46 PM 伊藤和也 wrote: > > Can I say that a pointer is a reference or memory address to a value? Sure. 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, se

Re: [go-nuts] Re: Temporarily allow unused variables

2019-01-09 Thread Ian Lance Taylor
On Wed, Jan 9, 2019 at 1:46 PM wrote: > > So, 2019 year. Still no compiler flag. Slphers :) This isn't a matter of being slow, it's an intentional decision. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group

Re: [go-nuts] How to append nil using reflect

2019-01-10 Thread Ian Lance Taylor
On Thu, Jan 10, 2019 at 3:40 PM wrote: > > I want to append a nil value using reflect.Append(), but I got a panic: > reflect: call of reflect.Value.Set on zero Value. > > This is my code. > > s := make([]interface{}, 10) > v := reflect.ValueOf(nil) > reflect.Append(reflect.ValueOf(s), v) > > So i

Re: [go-nuts] go test linking time issue

2019-01-11 Thread Ian Lance Taylor
On Fri, Jan 11, 2019 at 5:49 AM wrote: > > I'm working on pretty big golang project. This project consists of several > hundreds of packages, most of them are with tests. When we run tests, go test > tool does the following: > > * for each package with test files it extends this package with *_t

Re: [go-nuts] What's the best way to detect if CGO is enabled?

2019-01-14 Thread Ian Lance Taylor
On Mon, Jan 14, 2019 at 3:26 PM wrote: > > Whether CGO is enabled or not affects how reliable certain standard library > functions are. For example, os/user.LookupGroupId is untrustworthy if CGO is > not enabled (example 1, example 2). > > I can use build flags and two separate source files to d

Re: [go-nuts] what is the use of context in golang RESTful apis?

2019-01-16 Thread Ian Lance Taylor
On Wed, Jan 16, 2019 at 5:39 AM Robert Engels wrote: > > A big difference of opinion here. TLS as implemented in Java via ThreadLocal > is trivial to use, understand, and is pervasive. In C++ its a different story. A general form of TLS is much more confusing in a language where it's trivial to

Re: [go-nuts] what is the use of context in golang RESTful apis?

2019-01-16 Thread Ian Lance Taylor
> On Wed, Jan 16, 2019 at 7:15 AM Robert Engels wrote: > > > I don’t see the complexity nor the real difference between Go routines and > Threads. In Java TLS is not passed to new threads you need to be explicit. > The ThreadLocal doesn’t allow access to other threads locals even with > thread

Re: [go-nuts] help- i cant run program

2019-01-17 Thread Ian Lance Taylor
On Thu, Jan 17, 2019 at 5:41 PM wrote: > > hay > Help, while I'm running and getting this error > > > cannot find package "fmt" in any of: C:\Go\bin\src\fmt (from $GOROOT) > C:\Users\HP\go\src\fmt (from $GOPATH) package . imports runtime: cannot find > package "runtime" in any of: C:\Go\bin\src\

Re: [go-nuts] Accessing the build cache

2019-01-18 Thread Ian Lance Taylor
On Fri, Jan 18, 2019 at 5:34 AM Jan B wrote: > > Is there any way to access go's build cache? Specifically, i want to check if > the source files of my program have changed (i.e. it needs to be recompiled). > I've searched through the go tools but couldn't find anything that does this. I don't t

Re: [go-nuts] When marshalling values, should panics be preserved?

2019-01-18 Thread Ian Lance Taylor
On Fri, Jan 18, 2019 at 8:59 AM Robert Johnstone wrote: > > I'm working on a GUI library, and one of the facilities provided is a way to > execute code on the GUI thread. The call site is pretty simple: > > err := Do(func() error { > // Inside this closure, we will be executing only on the G

Re: [go-nuts] Re: What does "nil implay?

2019-01-21 Thread Ian Lance Taylor
On Mon, Jan 21, 2019 at 5:19 AM 伊藤和也 wrote: > > So what do you think "nil" represents instead? > "nil" is just a special value? for slices, maps. There is no one answer to that question. As you know, `nil` is the value of an uninitialized variable of interface, slice, pointer, map, function

Re: [go-nuts] identifier ... may conflict with identifiers generated by cgo

2019-01-21 Thread Ian Lance Taylor
On Mon, Jan 21, 2019 at 3:56 AM Tamás Gulácsi wrote: > > Instead of > > ns := make([]*_Ctype_char, 2*len(namespaces)+1) > > Use > > > ns := make([]*C.char, 2*len(namespaces)+1) Let me add that using C.char has always been the documented and supported way to use cgo, and I have no

Re: [go-nuts] could functions returning multiple values make templates behind the scenes

2019-01-21 Thread Ian Lance Taylor
On Sun, Jan 20, 2019 at 2:44 PM 'simon place' via golang-nuts wrote: > > wouldn't the compiler be able to use the fact that a return value is known > not to be being used in a particular call, somewhere one or more of the > returned values are assigned to a blank, to be able to generate faster c

Re: [go-nuts] Re: Why is this an assignment count mismatch?

2019-01-21 Thread Ian Lance Taylor
On Sun, Jan 20, 2019 at 7:14 AM wrote: > > It can be verified by use of tuples > x, (y, z) := A[id1], B[id2] > > But the above doesn't work. Why ? Well, because that's not how the language works. The language doesn't support tuples. It supports some specific cases of assignment to multiple valu

Re: [go-nuts] could functions returning multiple values make templates behind the scenes

2019-01-21 Thread Ian Lance Taylor
ion. Yes, if you clone functions, then you can take advantage of the fact that some calls don't use the results. But cmd/compile doesn't currently clone functions (the gccgo compiler does). Ian > On Tuesday, 22 January 2019 00:00:47 UTC, Ian Lance Taylor wrote: >> >

Re: [go-nuts] Interpretting the pprof memory profile

2019-01-22 Thread Ian Lance Taylor
On Tue, Jan 22, 2019 at 11:21 AM Patrik Iselind wrote: > > I'm looking at memory profiles and have a hard time interpreting what I see. > I'm trying to better understand what I am looking at in `go tools pprof` why > looking at the raw data. All 'groups' at the end of output from > /debug/pprof

Re: [go-nuts] Re: do you use binary-only packages?

2019-01-22 Thread Ian Lance Taylor
On Tue, Jan 22, 2019 at 1:06 PM Wei Tang wrote: > > Well, I do think Binary-only packages are very important for some security > case, such as authentication algorithm in a private enterprise。 I would not recommend using them in that way. A binary package should be thought of as a slightly shro

Re: [go-nuts] could functions returning multiple values make templates behind the scenes

2019-01-22 Thread Ian Lance Taylor
On Tue, Jan 22, 2019 at 7:55 AM 'simon place' via golang-nuts wrote: > > thanks for the info, answered my OP, but raised some more questions... > > presumably the go runtime is compiled with gccgo? so would that mean there > are possibly cloned functions in it? When using gccgo, yes, and yes. >

Re: [go-nuts] Why not a mixture of value and pointer receiver?

2019-01-22 Thread Ian Lance Taylor
On Tue, Jan 22, 2019 at 1:59 PM Xinhu Liu wrote: > > In "A Tour of Go" I read: > >> In general, all methods on a given type should have either value or pointer >> receivers, but not a mixture of both. > > > But why not? > > Methods having value receiver can be called by both value type and pointe

Re: [go-nuts] why map the key type must not be a function, map, or slice

2019-01-22 Thread Ian Lance Taylor
On Tue, Jan 22, 2019 at 7:59 PM wrote: > > When i use the func, map slice as the key of map, it isn't work! > So I lookup source why, i find You don't have to look at the source, you can look at the language spec. https://golang.org/ref/spec#Map_types "The comparison operators == and

Re: [go-nuts] Re: why map the key type must not be a function, map, or slice

2019-01-23 Thread Ian Lance Taylor
On Tue, Jan 22, 2019 at 11:47 PM wrote: > > i got : > # command-line-arguments > ./key.go:6:18: invalid operation: F() == F() (func can only be compared to > nil) Yes, that is what the language spec says and it is what I said: in Go, function values are not comparable. I wrote that code as an

Re: [go-nuts] Is it possible to export a variable from main package? If impossible, why?

2019-01-23 Thread Ian Lance Taylor
Yes, you can export a variable from the main package. It's not very useful, since normally nothing will import the package, but you can do it if you want. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and st

Re: [go-nuts] The performance comparation of Golang and Java

2019-01-24 Thread Ian Lance Taylor
On Thu, Jan 24, 2019 at 6:21 PM Topget wrote: > > I have tested several simple functions with Golang and Java. To my surprise, > Java sometimes is faster than Golang(especially in recursive function and > some function in standard library such as math/rand.Rand). I wonder why. Here > is some co

Re: [go-nuts] The performance comparation of Golang and Java

2019-01-24 Thread Ian Lance Taylor
Fibonacci. The recursive function that you wrote has complexity O(2 ** N). Write a simple loop, complexity O(N). Ian > On Fri, Jan 25, 2019 at 8:26 AM Ian Lance Taylor wrote: >> >> On Thu, Jan 24, 2019 at 6:21 PM Topget wrote: >> > >> > I have tested sever

Re: [go-nuts] Re: the latest "go install"

2019-01-25 Thread Ian Lance Taylor
On Fri, Jan 25, 2019 at 3:36 AM Scott Cotton wrote: > > +1 > > On Friday, 25 January 2019 08:53:13 UTC+1, Daniel Skinner wrote: >> >> This will probably sound stupid, but I think it's important; I recently >> tried to install a util I had written in Go that depended on a third party >> library a

Re: [go-nuts] Why makechan distinguish elements do not contain pointers or contain pointers?

2019-01-25 Thread Ian Lance Taylor
On Thu, Jan 24, 2019 at 11:58 PM wrote: > > go 1.11.1 source code is below: > > Generally speaking, make chan just pay attention to the presence or absence > of buf. > > When I saw the source code of make chan, I can understand case 1: chan buf > is 0, but can't understand case 2 & default. > >

Re: [go-nuts] go 1.11.4 build issue

2019-01-25 Thread Ian Lance Taylor
On Fri, Jan 25, 2019 at 12:52 PM gocss wrote: > > xubuntu 18.04 LTS > > ./buildall.bash > > 2 areas of concern ... how to resolve? > > #1 ) ### Building linux-riscv64 Unfortunately, riscv64 is not supported. Adding riscv support is https://golang.org/issue/27532. Ian -- You received this

Re: [go-nuts] go install touches the result file even if no changes

2019-01-25 Thread Ian Lance Taylor
On Fri, Jan 25, 2019 at 1:07 PM 'Tim Hockin' via golang-nuts wrote: > > Example: > > ``` > $ which git-sync > > $ go install -installsuffix "static" ./cmd/git-sync/ > > $ ls -l --full-time `which git-sync`; md5sum `which git-sync` > -rwxr-xr-x 1 thockin primarygroup 13956902 2019-01-25 > 13:04:40.

Re: [go-nuts] About 64bits alignment

2019-01-25 Thread Ian Lance Taylor
On Fri, Jan 25, 2019 at 2:59 PM wrote: > > I still can't find anything "authoritative and unambiguous" on this. > Therefore apps are going to be released with bugs in them. Can someone > please say specifically when it is _not_ safe to use 64-bit atomic operations? > > When it is unsafe on a 6

Re: [go-nuts] go install touches the result file even if no changes

2019-01-25 Thread Ian Lance Taylor
need a more complex API? Let me turn it around: why do you care? For cases where you do care, could you instead keep a hash of the file contents? For what it's worth, you can fetch a hash of a Go program by running "go tool buildid PROGRAM". See https://golang.org/cmd/buildid. Ian

Re: [go-nuts] go install touches the result file even if no changes

2019-01-26 Thread Ian Lance Taylor
On Fri, Jan 25, 2019 at 7:55 PM Tim Hockin wrote: > > Fair point, of course. > > I care because Kubernetes and it's family of projects have Makefiles to > encapsulate trickier aspects of building, including code generation. > Compiling kubernetes takes a LONG time. It would be nice to avoid >

Re: [go-nuts] About 64bits alignment

2019-01-26 Thread Ian Lance Taylor
On Sat, Jan 26, 2019 at 7:56 AM Marvin Renich wrote: > > * Ian Lance Taylor [190125 18:11]: > > On Fri, Jan 25, 2019 at 2:59 PM wrote: > > > I still can't find anything "authoritative and unambiguous" on this. > > > Therefore apps are going to be r

Re: [go-nuts] Why makechan distinguish elements do not contain pointers or contain pointers?

2019-01-26 Thread Ian Lance Taylor
te as Go 1.6, but there is no such flag in current versions of Go. Ian > 在 2019年1月25日星期五 UTC+8下午10:58:44,Ian Lance Taylor写道: >> >> On Thu, Jan 24, 2019 at 11:58 PM wrote: >> > >> > go 1.11.1 source code is below: >> > >> > Generally speaking,

Re: [go-nuts] Why makechan distinguish elements do not contain pointers or contain pointers?

2019-01-26 Thread Ian Lance Taylor
mory allocation is still difficult to understand. What reference > materials can help me understand the context of this block? There is some information at golang.org/s/go14gc but I'm not sure it quite covers what you are looking for. Ian > 在 2019年1月27日星期日 UTC+8上午3:03:47,Ian Lance Tayl

Re: [go-nuts] go install touches the result file even if no changes

2019-01-28 Thread Ian Lance Taylor
ge is Turing complete (although some limits are applied to rule expansion so you can't write an infinite loop). Ian > On Sat, Jan 26, 2019 at 11:01 AM Ian Lance Taylor wrote: > > > > On Fri, Jan 25, 2019 at 7:55 PM Tim Hockin wrote: > > > > > > Fair point, of cour

Re: [go-nuts] Why makechan distinguish elements do not contain pointers or contain pointers?

2019-01-28 Thread Ian Lance Taylor
Otherwise we might mistake an integer for a pointer. Knowing where those pointers are requires knowing the type of the object. Ian > 在 2019年1月27日星期日 UTC+8下午1:55:29,Ian Lance Taylor写道: >> >> On Sat, Jan 26, 2019 at 6:50 PM wrote: >> > >> > I am looking at go1.11

Re: [go-nuts] Binary only package stub file

2019-01-28 Thread Ian Lance Taylor
On Mon, Jan 28, 2019 at 1:56 PM Aakash das wrote: > > Hello everyone, > The requirements for binary only source file has changed in Go 1.10. Could > you please guide me to the steps that are needed for making binary only > package work with Go 1.10. I couldn't find any example on generating a st

Re: [go-nuts] Unbuffed channel vs Buffered channel.

2019-01-28 Thread Ian Lance Taylor
On Mon, Jan 28, 2019 at 4:44 PM 伊藤和也 wrote: > > Questions: > 1. As the name says, doesn't an unbuffered channel use a buffer? Sorry, I'm not sure what you are asking. An unbuffered channel does not use a buffer. A buffered channel does use a buffer. > 2. If so, does an unbuffered channel use a

Re: [go-nuts] What does a deadlock mean in golang?

2019-01-29 Thread Ian Lance Taylor
On Tue, Jan 29, 2019 at 12:55 AM 伊藤和也 wrote: > > I know the general meaning of a deadlock, but I don't know the meaning of a > deadlock in golang. For example, I send 4 values to a buffered channel whose > maxmum size is 3 and a deadlock occurs. I think this is just "values are out > of bounds"

Re: [go-nuts] Binary only package stub file

2019-01-29 Thread Ian Lance Taylor
efined references to PKG.init. That should give you the list of imported packages. I'm not completely sure if every imported package will be listed reliably in that way, though. Ian >> On Tue, Jan 29, 2019 at 3:59 AM Ian Lance Taylor wrote: >>> >>> On Mon,

Re: [go-nuts] Re: Memory usages

2019-01-30 Thread Ian Lance Taylor
On Wed, Jan 30, 2019 at 4:40 PM 伊藤和也 wrote: > > I thought "100" has a specific size then "num" has the copy of "100". In a compiled language like Go it's not very useful to think about the size of numeric constants. Think about the sizes of variables. Numeric constants exist only in the instruct

Re: [go-nuts] When initializing variables, copies of values are made?

2019-01-31 Thread Ian Lance Taylor
On Thu, Jan 31, 2019 at 4:48 PM 伊藤和也 wrote: > > When initializing variables, If the copies of values are made, their memory > usages will be: > >> var a = [3]int8{2, 4, 6} >>| | >> >> 3 bytes + 3 bytes = 6 bytes > > >> var b = []int8[2, 4, 6} >>| | >>

Re: [go-nuts] show and hide option for docs on online src

2019-02-05 Thread Ian Lance Taylor
On Tue, Feb 5, 2019 at 8:12 AM Sadegh Nikaein wrote: > > Is it better add some option on online src to hide all document on source > code ? Why? Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop recei

Re: [go-nuts] Find biggest memory holder

2019-02-07 Thread Ian Lance Taylor
On Thu, Feb 7, 2019 at 2:33 AM Thomas S wrote: > > But now, to go forward, I need a monitoring of my globals variables. > And not of the "run consumption" of ram. > > Any ideas on how to do this efficiently ? The size of your global variables doesn't change during execution of your program, of co

Re: [go-nuts] Find biggest memory holder

2019-02-07 Thread Ian Lance Taylor
On Thu, Feb 7, 2019 at 1:33 PM Thomas S wrote: > > Yes Indeed, the size are changing, because it's trees mainly, and some > maps/slices To be clear, any changes to the trees, maps, whatever, will appear in the normal memory profile. Ian -- You received this message because you are subscribed

Re: [go-nuts] Re: About 64bits alignment

2019-02-07 Thread Ian Lance Taylor
On Thu, Feb 7, 2019 at 3:49 PM T L wrote: > > Is the bug zone outdated now. How about the support on other 32-bit archs? > Such as mips? The bug description is not out of date. Yes, 32-bit MIPS also requires 8 byte alignment for the 64-bit operations. I sent https://golang.org/cl/161697 to upd

Re: [go-nuts] Alternative of defer?

2019-02-09 Thread Ian Lance Taylor
On Fri, Feb 8, 2019 at 7:48 PM Robert Engels wrote: > > The way Go is designed a panic must terminate the application. Anything else > is so indeterminate to be unusable. I think one can reasonably argue that an unrecognized panic should terminate the application. But there is nothing wrong wit

Re: [go-nuts] Intercepting goroutine context switching

2019-02-09 Thread Ian Lance Taylor
On Sat, Feb 9, 2019 at 2:02 PM wrote: > > I am looking at fine-grained calling context collection for go lang programs > (for all go routines) using binary instrumentation tools such as Intel Pin. > In a traditional language such as C/C++ intercepting CALL/RET instructions > (plus some special h

Re: [go-nuts] Parsing date with Timezone doesn't return UTC

2019-02-11 Thread Ian Lance Taylor
On Mon, Feb 11, 2019 at 10:53 AM wrote: > > Hi all, please could you help me with a simple problem? > > I have some parsing code like this: https://play.golang.org/p/6bVyWg4FCVN > > It writes > > 20190211T103847+ > > 2019-02-11 10:38:47 + UTC > > > on the server. > > When I put the code i

Re: [go-nuts] Intercepting goroutine context switching

2019-02-11 Thread Ian Lance Taylor
On Sat, Feb 9, 2019 at 5:07 PM Milind Chabbi wrote: > > Can you give me more details about these terms: "g0", "systemstack", and > "mcall"? In Go, goroutines are multiplexed on to threads, so there are typically many more goroutines than there are threads. Each thread has an associated goroutin

Re: [go-nuts] Golang closures, counter-intuitive behaviour

2019-02-11 Thread Ian Lance Taylor
On Mon, Feb 11, 2019 at 4:48 PM Slawomir Pryczek wrote: > > When looking at this code below, you can see that the function will get LAST > value of i which is incremented inside the loop, but t is somehow copied and > taken inside a function so closure is created and it is bound to current > va

Re: [go-nuts] How to run some unittest repeatedly without build cache?

2019-02-11 Thread Ian Lance Taylor
On Mon, Feb 11, 2019 at 10:32 PM Cholerae Hu wrote: > > Some bugs caused by data race cannot be detected by running unittest only > once. Before Go 1.12, I can use GOCACHE=off go test -race . to force it to > run without cache, but GOCACHE=on is required as of Go 1.12. So how can I > workaround

Re: [go-nuts] Go - logo commercial use

2019-02-13 Thread Ian Lance Taylor
On Wed, Feb 13, 2019 at 3:15 PM wrote: > > I would love to be able to include your logo as part of our inventory > (sticker site) but aren’t sure of the restrictions regarding its use for > commercial purposes, so we would like to find out what your policy is > regarding this and if this would

Re: [go-nuts] How to do a cleanup of context cancelling?

2019-02-14 Thread Ian Lance Taylor
On Thu, Feb 14, 2019 at 2:13 AM Jingguo Yao wrote: > > https://blog.golang.org/context uses the following code to cancel the request > if ctx.Done is closed before the goroutine exits: > > func httpDo(ctx context.Context, req *http.Request, f func(*http.Response, > error) error) error { > //

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

2019-02-19 Thread Ian Lance Taylor
On Tue, Feb 19, 2019 at 9:34 AM Manlio Perillo wrote: > > The Go language specification never mentions undefined behavior, however > Ian Lance Taylor wrote, in [1], that: > > - if your program has a race condition, the behavior is undefined. > > [1] https://groups.google.com

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

2019-02-19 Thread Ian Lance Taylor
On Tue, Feb 19, 2019 at 10:04 AM Harald Weidner wrote: > > I would also consider the order in which init() functions of the same > package are executed undefined. The spec says they are executed "in the > order they appear in the source, possibly in multiple files, as presented > to the compiler".

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

2019-02-19 Thread Ian Lance Taylor
On Tue, Feb 19, 2019 at 11:06 AM Manlio Perillo wrote: > > On Tuesday, February 19, 2019 at 7:26:22 PM UTC+1, Ian Lance Taylor wrote: >> >> On Tue, Feb 19, 2019 at 9:34 AM Manlio Perillo wrote: >> > >> > The Go language specification never mentions undefi

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