Re: [go-nuts] How to access pointer to pointer in cgo

2017-07-05 Thread Jan Mercl
On Wed, Jul 5, 2017 at 1:04 PM Manohar Reddy wrote: > fmt.Println(optional._32.Magic) // did not work for me: HOW TO ACCESS MAGIC VARIABLE Who wants to guess what does "did not work for me" mean without having the source code and the compiler output to look at? Please post a complete example at

Re: [go-nuts] Capture test output per-function

2017-07-06 Thread Jan Mercl
On Thu, Jul 6, 2017 at 12:56 AM wrote: > As far as I can tell, go test captures the output per-package, and when one test fails it dumps all the captured logs. It's per test, not package. jnml@r550:~/tmp/test$ ls all_test.go jnml@r550:~/tmp/test$ cat all_test.go package foo import "testing" f

Re: [go-nuts] Capture test output per-function

2017-07-06 Thread Jan Mercl
You should never use fmt.Printf in a test. Use t.Logf instead. On Thu, Jul 6, 2017, 17:29 wrote: > On Thursday, July 6, 2017 at 12:40:30 AM UTC-7, Jan Mercl wrote: > >> On Thu, Jul 6, 2017 at 12:56 AM wrote: >> >> > As far as I can tell, go test captures the output p

Re: [go-nuts] does Go memory model guarantee this program always prints 1?

2017-07-09 Thread Jan Mercl
On Sun, Jul 9, 2017 at 10:56 AM T L wrote: > But I remember that the "happens-before relationship" is never written down in any official Go documentation. https://golang.org/ref/mem#tmp_2 -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" grou

Re: [go-nuts] My project is now missing from godoc

2017-07-09 Thread Jan Mercl
On Sun, Jul 9, 2017, 16:35 Tong Sun wrote: > Hi, > > My project is *now* missing from godoc, the > http://godoc.org/github.com/go-easygen/easygen > is *now* returning "Not Found". > > It has always been working before, for > https://github.com/go-easygen/easygen > > What's wrong? Thx. > Try to r

Re: [go-nuts] My project is now missing from godoc

2017-07-09 Thread Jan Mercl
On Sun, Jul 9, 2017, 16:45 Tong Sun wrote: > > > On Sun, Jul 9, 2017 at 10:41 AM, Jan Mercl wrote: > > >> >> On Sun, Jul 9, 2017, 16:35 Tong Sun wrote: >> >>> Hi, >>> >>> My project is *now* missing from godoc, the >>> http:

Re: [go-nuts] does Go memory model guarantee this program always prints 1?

2017-07-10 Thread Jan Mercl
On Mon, Jul 10, 2017 at 2:24 PM T L wrote: > Aha, what I wanted to express is the execution orders of the two lines may be randomized. > > atomic.AddInt32(&x, 1) > atomic.AddInt32(&y, 1) No, assuming those two lines are as written, ie. part of single function and thus executed in a single/the sa

Re: [go-nuts] Re: Random Number Generation in a given range

2017-07-10 Thread Jan Mercl
On Mon, Jul 10, 2017 at 4:41 PM Alok Kumar Singh wrote: > in my usecasei use this to generate random slice everytime > dont want the same result > using it to test my algos For that you need one only call to Seed at init(). -- -j -- You received this message because you are subscribed to th

Re: [go-nuts] why I got a panic in this code?

2017-07-11 Thread Jan Mercl
On Tue, Jul 11, 2017 at 11:24 AM Fino wrote: > https://play.golang.org/p/2Wd9xlztBr Because of the reason the runtime error message unambiguously says: index out of range. Check https://play.golang.org/p/AZ3FEWUyPm -- -j -- You received this message because you are subscribed to the Google

Re: [go-nuts] slow Mod function in math/big, a better way?

2017-07-17 Thread Jan Mercl
On Mon, Jul 17, 2017 at 3:57 PM Jeff Templon wrote: > Coming back to this, now that my Go knowledge is increasing: Out of curiosity, how big are the numbers you want to factorize? -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsu

Re: [go-nuts] slow Mod function in math/big, a better way?

2017-07-17 Thread Jan Mercl
On Mon, Jul 17, 2017 at 4:09 PM Jeff Templon wrote: > Generally I'm factoring numbers that I can do in less than a day, so in the order of 60 to 100 decimal digits. Just for fun: Please provide a sample in that range. -- -j -- You received this message because you are subscribed to the Goog

Re: [go-nuts] slow Mod function in math/big, a better way?

2017-07-17 Thread Jan Mercl
On Mon, Jul 17, 2017 at 7:18 PM Jeff Templon wrote: > Sure: I hoped for a number of which you don't know the factors and wanted to cheat by linking to factordb.com ;-) Earlier you wrote also > it turns out that 77% of the time of the program is spent in runtime.mallocgc :-) I think the reason

Re: [go-nuts] Expiring map

2017-07-19 Thread Jan Mercl
On Wed, Jul 19, 2017 at 9:22 PM Rajanikanth Jammalamadaka < rajanika...@gmail.com> wrote: > Does somebody have a recommendation for an expiring dict? If I have to write my own, is there a way to avoid iterating over all the keys to delete the expired entries? Common approach is to tag the entries

Re: [go-nuts] go get awkwardness with packages outside of GOPATH

2017-07-19 Thread Jan Mercl
On Wed, Jul 19, 2017 at 8:45 PM 'Florian Uekermann' via golang-nuts < golang-nuts@googlegroups.com> wrote: > tldr: Please let me update dependencies of packages that are in arbitrary directories. Dependencies are derived from import paths. Import paths are not complete paths. They are transformed

[go-nuts] Re: Pointer dereference operator precedence

2017-07-19 Thread Jan Mercl
Consider var x *[N]*T What is the type of *x[0]? *T or T? Only the parentheses can disambiguate it: (*x)[0] vs *(x[0]). On Thu, Jul 20, 2017, 00:28 wrote: > A question on Stack Overflow led me to carefully examine the spec and I > feel like there may be some detail that's missing - the behavio

Re: [go-nuts] Sorting user defined collection in multiple ways

2017-07-21 Thread Jan Mercl
On Fri, Jul 21, 2017 at 3:17 PM wrote: > - I have user defined data structure called Employee with attributes "age", name and sal. I want to write three different go functions that sorts based on age, name and sal. Are you sorting a slice? https://golang.org/pkg/sort/#Slice -- -j -- You rec

Re: [go-nuts] Re: Inconsistent rounding with float printf ?

2019-12-06 Thread Jan Mercl
On Fri, Dec 6, 2019 at 6:04 PM Christophe Meessen wrote: > I can't change expectations. It is to convert a byte count into a human > readable byte count ( with kB, MB, ... units). So it was an XY problem? No floating point operations are necessary to do that. Also, check several existing libra

Re: [go-nuts] Re: Where is the middle of Brazil?

2019-12-07 Thread Jan Mercl
On Sat, Dec 7, 2019 at 2:34 PM JuciÊ Andrade wrote: > I am pretty sure there are other ways to do it, but the method I devised is > simple and produces a good enough result. If somebody can put a hole in my > reasoning, feel free to do so. > > All the info I need are in a map, OK? So I download

Re: [go-nuts] Re: Why Iran is banned by Google?

2019-12-09 Thread Jan Mercl
On Mon, Dec 9, 2019 at 5:57 PM wrote: > So in simpler words, Google has banned Iran, right? Wrong. Michael was, 5 years ago, very precise and clear about the facts, which are exactly the opposite. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group

Re: [go-nuts] Assigning a value to a function pointer

2019-12-23 Thread Jan Mercl
On Mon, Dec 23, 2019 at 2:49 PM wrote: > But I cannot find any way of assigning a value to the function pointer `f` > even using the `unsafe` package. https://play.golang.org/p/qP5kuSCW6dO Note that while you can a pointer to a function, you rarely need that. Function is just a value like int

Re: [go-nuts] Assigning a value to a function pointer

2019-12-23 Thread Jan Mercl
On Mon, Dec 23, 2019 at 6:41 PM wrote: >> > But I cannot find any way of assigning a value to the function pointer `f` >> > even using the `unsafe` package. >> >> https://play.golang.org/p/qP5kuSCW6dO > > Thanks, unfortunately the asm shows that what gets into `f` is the stack > address of `f0`

Re: [go-nuts] Enforcing a type name rather than a variable name

2020-01-04 Thread Jan Mercl
On Sat, Jan 4, 2020 at 12:28 AM wrote: > > Hello, > > Is there any way to avoid the compilation error "*error is not a type" of > this example https://play.golang.org/p/gWNStGSCfTm ? > I understand the variable named `error` hides the type named `error` but is > there some other syntax to specif

Re: [go-nuts] Is the GC recovering storage when full slice expression reduce capacity ?

2020-01-10 Thread Jan Mercl
On Fri, Jan 10, 2020 at 9:52 AM Christophe Meessen wrote: > > It is possible to reduce the capacity of a slice by using the full slice > expression (https://golang.org/ref/spec#Slice_expressions). > > Now consider the following code where a is a 1MB slice. I then create b, a > slice of a, but wi

Re: [go-nuts] Language spec question: why is k, v := k, v allowed in a for loop with range?

2020-01-12 Thread Jan Mercl
On Sun, Jan 12, 2020 at 10:10 AM Silvan Jegen wrote: > So the declaration of the variables in the for loop itself is in outer > scope compared to the body of the for loop? The outer scope begins immediately after the keyword "for". The inner one is an ordinary block scope and it begins immediate

Re: [go-nuts] Is the GC recovering storage when full slice expression reduce capacity ?

2020-01-13 Thread Jan Mercl
On Sat, Jan 11, 2020 at 4:43 AM wrote: >> But there's one guarantee - the "dead" slice portion after >> cap will not be scanned by the collector if no other live object uses >> it. > > > That's not correct. If there is a reference to an object, the entire object > is live and is scanned, regardl

[go-nuts] Re: [golang-dev] Go 1.14 Release Candidate 1 is released

2020-02-08 Thread Jan Mercl
On Wed, Feb 5, 2020 at 8:43 PM Carlos Amedee wrote: > We have just released go1.14rc1, a release candidate version of Go 1.14. I am glad to report substantial improvements for a set of benchmarks of the gocc compiler[0], which is an experimental/WIP C compiler implemented in Go that can also pro

Re: [go-nuts] Re: vim-go autocompletion / help for struct members / function parameters

2020-02-17 Thread Jan Mercl
On Sun, Feb 16, 2020 at 9:38 AM Johann Höchtl wrote: > > Anybody? My question was not meant to criticize vim-go or gopls, if they > can't (yet) do what I want those tools to support me, but a honest questions > if I do not know how to use the tools. I no more use vim-go, I've switched from vim-

Re: [go-nuts] Re: stringer command and generated String() function

2020-02-18 Thread Jan Mercl
On Tue, Feb 18, 2020 at 9:47 AM Brian Candler wrote: > > Could you provide a link to where you found this code? I imagine it was done > that way just for demonstrating some features of go, such as slicing and > array lookups. > > A simpler and faster way again would be to use a map. > https://p

Re: [go-nuts] Re: stringer command and generated String() function

2020-02-18 Thread Jan Mercl
On Tue, Feb 18, 2020 at 10:37 AM Vincent Blanchon wrote: > @Jan, yes definitely. By the way, here are some numbers from a benchmark I > made with 20 constants: > > name time/op > Stringer-4 4.16ns ± 2% > > StringerWithSwitch-4 3.81ns ± 1% > > StringerWithMap-4

Re: [go-nuts] Re: stringer command and generated String() function

2020-02-18 Thread Jan Mercl
On Tue, Feb 18, 2020 at 11:10 AM Vincent Blanchon wrote: > @Jan Thank you for the feedback. I will try with a higher number of > constants. By the way, my benchmark tries all the path: > > func BenchmarkStringerWithSwitch(b *testing.B) { >for i := 0; i < b.N ; i++ { > p := Pill(i%20)

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-18 Thread Jan Mercl
On Tue, Feb 18, 2020 at 12:09 PM wrote: > > Regarding pointers: For me, point number 2 (and 3) is the key that forces us > having some way of expressing emptiness in a pointer. I'd say that nil pointers are not really special. It's just a sentinel value. And we definitely need some sentinel valu

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-18 Thread Jan Mercl
On Tue, Feb 18, 2020 at 12:44 PM wrote: > Well, other languages use the optional/maybe type. The CPU does not care how humans call the abstraction. It has still to do the same old thing: check some value for being equal/not equal to a sentinel value or check a tag value for the same effect. That

Re: [go-nuts] Re: stringer command and generated String() function

2020-02-18 Thread Jan Mercl
On Tue, Feb 18, 2020 at 1:47 PM Vincent Blanchon wrote: > However, in real code, I guess we will have that many constants, so it does > not make really sense to increase the number. Design decisions may be driven by the desire to maximize the performance in the average case or in the worst case

[go-nuts] Re: Proposal: Implement an interface based on function signature if method name is ambiguous. #37280

2020-02-18 Thread Jan Mercl
No need for a language change: https://play.golang.org/p/l7Cvf2fKzx4 -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To

Re: [go-nuts] Re: [Proposal] Change how gofmt formats struct fields

2020-02-20 Thread Jan Mercl
On Wed, Feb 19, 2020 at 7:26 PM Wojciech S. Czarnecki wrote: > https://github.com/golang/go/issues/37299 "I propose to add an opt-in go fmt solution meant to minimize whitespace changes to the block where a code author hinted at desired comments position." I believe the absence of any gofmt kno

Re: [go-nuts] [Go Spec]Confused about Assignability in Golang Specification

2020-02-23 Thread Jan Mercl
Both string1 and str1 have defined types while the quoted specs rule says "at least one of V or T is not a defined type.". On Sun, Feb 23, 2020, 14:19 Jimu Yang wrote: > I am reading the doc about Assignability in Golang Specification > . It says: > >

Re: [go-nuts] Re: [Go Spec]Confused about Assignability in Golang Specification

2020-02-23 Thread Jan Mercl
Type literals are a prime example of "undefined" types. For example as in `var a []int`. On Sun, Feb 23, 2020, 17:21 Jimu Yang wrote: > Thank you all. > i read all about defined types on the doc > https://golang.org/ref/spec#String_types > now i know many defined types (string bool int ...

Re: [go-nuts] Should it panic when set a channel to nil concurrently

2020-03-01 Thread Jan Mercl
On Mon, Mar 2, 2020 at 6:36 AM burak serdar wrote: > Why should it panic? The first goroutine simply sets the channel to > nil. The second goroutine will either block reading from a non-nil > channel, or block reading from a nil channel. There is no code in this > program that would panic. It ca

Re: [go-nuts] Should it panic when set a channel to nil concurrently

2020-03-01 Thread Jan Mercl
On Mon, Mar 2, 2020 at 6:56 AM burak serdar wrote: > At this point, channel receive is still holding a reference to the > channel (right?), so GC cannot free it. Depends very much on what code the compiler for channel receive generates and on the code in the runtime that implements the channel r

Re: [go-nuts] Re: Memory leak or GC feature ?

2020-03-06 Thread Jan Mercl
On Fri, Mar 6, 2020 at 4:55 PM Christophe Meessen < christophe.mees...@gmail.com> wrote: > It would have been convenient for detecting memory leaks to be able to compare memory Alloc before and after the checked task and a really complete GC. That's not feasible. There are _always_ other runtime-

Re: [go-nuts] append slice concurrently without lock,after that panic occurred when iterate the slice

2020-03-09 Thread Jan Mercl
On Mon, Mar 9, 2020 at 4:16 PM Yuu LongXue wrote: > > Hi all, > > Slice is not thread safe for write operation if without lock, this is true > and I know this feature. but recently, I got a panic which caused by writing > a slice concurrently with out lock occasionally and I can't figure out why

Re: [go-nuts] Does os.exec work ?

2020-03-25 Thread Jan Mercl
On Wed, Mar 25, 2020 at 7:30 PM wrote: > > This simple command works correctly when submitted via the terminal, but the > same command submitted to os.exec does not !! > .. and I can`t understand why... os.Exec does not pass commands to the shell, but it is the case in the terminal. Try somethin

Re: [go-nuts] Re: Slice reuse + GC

2020-03-27 Thread Jan Mercl
On Fri, Mar 27, 2020 at 8:19 AM Leszek Kubik wrote: > A fix for the situation of the topic could be implemented by the slice type. > Imagine, if a slice value not only shared the pointer to the underlying > buffer but also a list with references to all other slices holding on to the > underlyi

Re: [go-nuts] project mdencode first random file signature

2020-04-06 Thread Jan Mercl
On Sun, Jan 14, 2018 at 5:37 AM ankarame wrote: > mdencode is written in golang and uses an interface for pluggin formatters. The name of the language is Go. There's no golang language. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubs

Re: [go-nuts] project mdencode first random file signature

2020-04-06 Thread Jan Mercl
On Mon, Apr 6, 2020 at 10:00 AM ankarame wrote: > You can refer to it as Golang. You can call it any way you like. But still there's no golang language. Never was. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group

Re: [go-nuts] project mdencode first random file signature

2020-04-06 Thread Jan Mercl
On Mon, Apr 6, 2020 at 10:20 AM ankarame wrote: > That's not the point. It can be referred to as Golang. Here's the point. One thing is how you call it and you _can_ call it any way you like. The other thing is that there's no golang language. I can call you John Lennon but you're not becoming

Re: [go-nuts] project mdencode first random file signature

2020-04-06 Thread Jan Mercl
On Mon, Apr 6, 2020 at 2:38 PM ankarame wrote: > The user group is named golang-nuts. > Not go-nuts. Yes, the _mailing list_ named golang-nuts definitely exists. We are right here. Still there's no golang language. Never was. Maybe someone creates one in the future. Google index/search will hav

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

2020-04-06 Thread Jan Mercl
On Mon, Apr 6, 2020 at 6:08 PM Andy Balholm wrote: > > In looking back over some of these old conversations about converting C to > Go, I realized that there is some confusion about the different programs > named "c2go". There are basically 2: Make it 3 please: modernc.org/gocc. Experimental, w

Re: [go-nuts] Packet parsing in Go

2020-04-21 Thread Jan Mercl
On Tue, Apr 21, 2020 at 6:08 PM Rakesh K R wrote: > In C, we used to typecast this array of uint8_t to predefined structure. Go has no casts. Regardless, one can do something similar using unsafe. But then - how it's planned to deal with the situation when the machine endianess does not match th

Re: [go-nuts] Converting a C char[] to []byte of string with cgo

2020-04-30 Thread Jan Mercl
On Thu, Apr 30, 2020 at 8:17 PM Dean Schulze wrote: > > I must be missing something pretty simple, but I have a C struct like this: > > typedef struct line > { > char hostname[HOSTNAME_MAX]; > char ip[IP_MAX]; > ... > } > > When I try to do the simple thing > > C.GoString(p.hostname)

Re: [go-nuts] Converting a C char[] to []byte of string with cgo

2020-04-30 Thread Jan Mercl
On Thu, Apr 30, 2020 at 10:06 PM Dean Schulze wrote: > > That gives this error (which I've gotten with just about everything I try): > > cannot use &p.mach_name (type *[25]_Ctype_char) as type *_Ctype_char in > argument to _Cfunc_GoString Oh yeah, should have been probably `C.GoString(&p.hostnam

Re: [go-nuts] Should an assignment from int to a type based on int succeed?

2020-05-08 Thread Jan Mercl
On Fri, May 8, 2020 at 2:46 PM wrote: > Or do I just fail to see the obvious... 'int' _is_ a defined type. It's predeclared in the universe scope. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receivin

Re: [go-nuts] Should an assignment from int to a type based on int succeed?

2020-05-08 Thread Jan Mercl
On Fri, May 8, 2020 at 3:29 PM Christoph Berger wrote: > So I conclude that the assignment of *int to intp succeeds because *int is > not a defined type and both *int and intp have the same underlying type *int. > > Looking through the ref spec I found a couple of places that mention some > def

Re: [go-nuts] Should an assignment from int to a type based on int succeed?

2020-05-08 Thread Jan Mercl
On Fri, May 8, 2020 at 4:31 PM Christoph Berger wrote: > Unfortunately, the connection between "predeclared" (or "implicitly declared" > as the first paragraph says) and "defined" is not at all obvious. Especially > as the definition of "defined type" refers to types explicitly declared via >

Re: [go-nuts] Should an assignment from int to a type based on int succeed?

2020-05-08 Thread Jan Mercl
On Fri, May 8, 2020 at 5:57 PM Axel Wagner wrote: > > I'm happy to report, that I *think* I found an inconsistency with error not > being a defined type: > https://play.golang.org/p/gpy6S17wzIM I don't follow. Type of x is not a defined type and neither is type of y. The underlying type of x is

Re: [go-nuts] Should an assignment from int to a type based on int succeed?

2020-05-08 Thread Jan Mercl
On Fri, May 8, 2020 at 10:58 PM 'Axel Wagner' via golang-nuts wrote: > Well, that's what the nomenclature used to be. It was changed, because the > term got ambiguous and confusing once type-aliases got introduced. Turns out, > it's still confusing because people confuse "defined" and "declared

[go-nuts] Packages "Not found" at godoc.org

2020-05-10 Thread Jan Mercl
It came to my attention that some of my packages are not accessible at godoc.org at the time of this writing (09:05 UTC). A sample of URLs that report "Not Found": https://godoc.org/modernc.org/strutil https://godoc.org/modernc.org/mathutil https://godoc.org/modernc.org/cc https://godoc.org/moder

Re: [go-nuts] Packages "Not found" at godoc.org

2020-05-10 Thread Jan Mercl
On Sun, May 10, 2020 at 11:22 AM Sebastien Binet wrote: > It seems like gitlab is going through some maintenance work (I get a 503 when > trying to reach the files of the packages you labeled as working). > Perhaps it's just that (and some caching effect)? Ah, you're right, now I'm getting a 50

Re: [go-nuts] Waitgroup.done wont Panic?

2020-05-13 Thread Jan Mercl
On Thu, May 14, 2020 at 8:18 AM sperberstephan via golang-nuts wrote: > Here: > https://play.golang.org/p/76AzuAiVGxL > > I thougt If the waitgroup gets below 0 there should be a Panic. > I understand that the goroutine is canceled. So maybe the defer Statement is > Not executed. > But why is the

Re: [go-nuts] Any solution to hide my source code written in Go and make it a library to develop in Go as well

2020-05-16 Thread Jan Mercl
On Sat, May 16, 2020 at 9:11 PM Billy Cui wrote: > I searched all the websites for such a solution, until Go1.2 there was a > buildmode archive, but it did not supported after 1.2, in the mean time, it > really don't have enough source code protected. > > Then I try use buildmode c-archive/c-sh

Re: [go-nuts] Weird problem that CPU is nearly 100%

2020-05-22 Thread Jan Mercl
On Fri, May 22, 2020 at 9:05 AM tokers wrote: > > Thanks for you reply. > > Yeah, we have the plan to upgrade our go version to 1.13.10. Note that 1.13 does not have goroutine preemption Ian was talking about wrt 1.14. -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] Re: Need help with go modules

2020-05-24 Thread Jan Mercl
On Sun, May 24, 2020 at 6:58 AM Henry wrote: > To create a Go Module, step inside your project folder, and type go mod init > where is the qualified name of your project. For > instance, if you want to call your project "github.com/henry/myproject", then > inside your myproject folder, type g

Re: [go-nuts] Build management mechanism for go lang

2020-05-26 Thread Jan Mercl
On Wed, May 27, 2020 at 7:00 AM wrote: > Instead of creating a bash file, is there any build management tool like > maven for go lang ? I want to do the version, dependency management and also > create build files etc. Please share what requirements are you missing in the standard tools `go mo

Re: [go-nuts] Assignment of pointer values in a struct...

2020-06-04 Thread Jan Mercl
On Thu, Jun 4, 2020 at 5:13 PM Trig wrote: > > And I did it again... posted from another gmail account by accident, and my > post is forever in 'approval status', lol. Basically what Robert here said. > > On Thursday, June 4, 2020 at 9:53:56 AM UTC-5, Robert Engels wrote: >> >> You need pointers

Re: [go-nuts] bytes.NewBuffer(make([]byte, 0, )) allocates 4096 bytes buffer

2020-06-11 Thread Jan Mercl
On Thu, Jun 11, 2020 at 6:50 PM Gautam Saha wrote: > > Trying to allocate an in-memory buff of small size (few bytes) using > bytes.NewBuffer(make([]byte, 0, )) > The allocated buffer has size 4096 bytes i.e. > than what I requested for. > Why is this so? Nowhere the docs say one can control th

Re: [go-nuts] For a .net developer,how long it takes to learn go completely?

2020-06-11 Thread Jan Mercl
On Thu, Jun 11, 2020 at 7:24 PM P Walizada wrote: > > For a .net developer,how long it takes to learn go completely? IMO Go can be learned in a day. Getting fluent and comfortable with it takes longer, but that depends on how much code one writes. The other question is, how long it takes in some

Re: [go-nuts] Go has eliminated most of my off-by-one errors except 0... I mean 1.

2020-06-13 Thread Jan Mercl
On Sat, Jun 13, 2020 at 4:42 PM Tom Limoncelli wrote: I'd suggest to just write the short 'end' function by yourself if you think it's useful for you. It does not harm performance as it will get inlined AFAICT. But it IMO hurts readability a bit. I'd prefer to read the explicit `len(x)-1` instea

Re: [go-nuts] Go has eliminated most of my off-by-one errors except 0... I mean 1.

2020-06-13 Thread Jan Mercl
On Sat, Jun 13, 2020 at 5:37 PM Jake Montgomery wrote: > You cant really write a short 'end()' function. You have to write an end > function for every type of slice. Or use reflection, which would make the > function slow, and not inlined. Generics anyone? I haven't mentioned anything about th

Re: [go-nuts] x, err = some_func(); if err != nil { } seems awkward

2020-06-14 Thread Jan Mercl
On Sun, Jun 14, 2020 at 5:25 PM Tom Limoncelli wrote: > > On Thu, Jun 4, 2020 at 3:34 PM Ian Lance Taylor wrote: > > > > On Thu, Jun 4, 2020 at 8:43 AM wrote: > > > > > > ?? Why not a cleaner syntax e.g. x = some_func () #{ } .. symbol # > > > arbitrarily chosen > > > > Besides what other p

Re: [go-nuts] Memory synchronization by channel operations and mutexes

2020-06-15 Thread Jan Mercl
On Mon, Jun 15, 2020 at 6:30 PM Leo Baltus wrote: > > from gopl chapter 9.4 'Memory synchronisation’ > > Synchronization primitives like channel communications and mutex operations > cause the processor to flush out and commit all its accumulated writes so > that the effects of goroutine executi

Re: [go-nuts] How I can translate this shell command to golang code?

2020-06-22 Thread Jan Mercl
On Mon, Jun 22, 2020 at 5:54 PM Franco Marchesini wrote: > how I can translate this shell command : > > echo -n 123456 | dmtxwrite -s 16x48 -o image.png Not tested: https://play.golang.org/p/Jh9ix17TlKG -- You received this message because you are subscribed to the Google Groups "golang-nuts

Re: [go-nuts] Expanding variables and fmt.Printf() issue

2020-06-29 Thread Jan Mercl
On Mon, Jun 29, 2020 at 9:22 AM yves baumes wrote: > If I use append() instead of Printf(), this expanding of the host variables > just works out. Is this a compiler bug in the case of the fmt.Printf() ? No bug. That's how variable arguments and assignability rules are specified to work. -- Y

Re: [go-nuts] Why does function escape to heap?

2020-06-29 Thread Jan Mercl
On Mon, Jun 29, 2020 at 5:15 PM Pure White wrote: > I would like to know: > 1. How can a function "escapes to heap"? Isn't it a pointer to the code > area? It is not: https://groups.google.com/forum/#!searchin/golang-dev/plan$20for$20two-word$20funcs$2C$20take$202%7Csort:date/golang-de

Re: [go-nuts] Goroutines count and id

2020-06-30 Thread Jan Mercl
On Tue, Jun 30, 2020 at 9:36 AM Durga Someswararao G wrote: > Is it possible to get goroutine id when we creted? > Is it possible to get goroutines count while we creating? > Is it possible to terminate a goroutine based on ID like if any goroutine has > infinite loops? > Is it possible to clean

[go-nuts] godoc.org pkg.go.dev banner feedback

2020-07-02 Thread Jan Mercl
godoc.org displays packages from the domain modernc.org just fine. It also adds a banner sayings, for example at https://godoc.org/modernc.org/cc/v3 "Pkg.go.dev is a new destination for Go discovery & docs. Check it out at pkg.go.dev/modernc.org/cc/v3 and share your feedback." However, c

Re: [go-nuts] godoc.org pkg.go.dev banner feedback

2020-07-06 Thread Jan Mercl
On Mon, Jul 6, 2020 at 9:03 PM 'Jonathan Amsterdam' via golang-nuts wrote: > Fixed in production. The links work now. Happy to confirm. Many thanks to everyone involved in making it happen. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To un

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Jan Mercl
On Tue, Jul 14, 2020 at 11:55 PM 'Robert Griesemer' via golang-nuts wrote: > The time has come to revisit this early decision. If square brackets alone > are used to declare type parameters, the array declaration My 2c - Alternative type parameters syntax (ab)using @$: https://docs.google.com/d

Fwd: [go-nuts] Generics and parentheses

2020-07-16 Thread Jan Mercl
Resending to the list after mistakenly replied off list. My apologies. On Wed, Jul 15, 2020 at 10:59 PM Ian Lance Taylor wrote: > Thanks for the detailed writeup. It might have been too detailed and suffered from low information density. Let me amend it with a tl;dr: 1. The main id

Re: [go-nuts] Generics and parentheses

2020-07-16 Thread Jan Mercl
On Thu, Jul 16, 2020 at 3:12 PM 'Axel Wagner' via golang-nuts wrote: > I dislike the idea of using $ and @ because I don't want to add new symbols > to the language, if it can be avoided. In general I'd argue that Go tends to > use keywords instead of symbols to convey meaning - e.g. we don't w

Re: [go-nuts] compress/flate

2020-07-17 Thread Jan Mercl
On Fri, Jul 17, 2020 at 11:23 AM Heisenberg wrote: > > Constant definition in token.go: > > literalType = 0 << 30 > > The only use I see is: > > func (t token) literal() uint32 { return uint32(t - literalType) } > func literalToken(literal uint32) token { return token(literalType + literal) > } >

Re: [go-nuts] is golang(1.13)'s parser is a LL(1) parser?

2020-07-17 Thread Jan Mercl
Go grammar is not LL(1) AFAICT. It's very close to LALR(1), but with an ambiguity that has a fully defined resolution in the language specification. On Fri, Jul 17, 2020, 17:28 xie cui wrote: > is golang(1.13)'s parser is a LL(1) parser? > > -- > You received this message because you are subscr

Re: [go-nuts] Re: Generics and parentheses

2020-07-18 Thread Jan Mercl
On Sat, Jul 18, 2020 at 7:22 AM Steve Ruble wrote: > Consider: > > a, b = w < x ; y > (z) That requires an unbound lookahead which is better avoided. -- 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] Re: Generics and parentheses

2020-07-18 Thread Jan Mercl
On Sat, Jul 18, 2020 at 11:44 AM Mariusz Gronczewski wrote: > pipe character isn't exactly used anywhere in Go, is on every keyboard and > looks decent enough: It's the bitwise binary or operator. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group

Re: [go-nuts] Generics and parentheses

2020-07-18 Thread Jan Mercl
On Sat, Jul 18, 2020 at 11:12 AM roger peppe wrote: Thanks for taking time to think about it. > A few reasons that I'm not keen on your $, @ proposal: > > - elsewhere in Go, when a name is defined, there is one clear construct that > defines it, not an arbitrary place within a type expression.

Re: [go-nuts] Generics and parentheses

2020-07-18 Thread Jan Mercl
On Sat, Jul 18, 2020 at 1:39 PM roger peppe wrote: > I didn't say there was exactly one construct for each kind of name > definition. In current Go, when a name is defined, it's defined inside a > construct that is explicitly about defining that name. By contrast, in your > proposal, we take a

Re: [go-nuts] Go 2 review process

2020-07-20 Thread Jan Mercl
On Mon, Jul 20, 2020 at 1:00 PM Markus Heukelom wrote: > > Would it be an idea to allow people only to label something as proposal if > they have at least some support / voucher for the idea? Say N>10 general > upvotes or 1 upvote from a golang committer? The problem is that not everyone has a

Re: [go-nuts] Allocating lots (e.g. a million) objects on the heap

2020-07-20 Thread Jan Mercl
Check https://godoc.org/modernc.org/memory, maybe it can be used in this scenario. Note, using the package concurrently from multiple goroutines requires coordination, like with a mutex. On Mon, Jul 20, 2020, 19:35 wrote: > I have an application where I will be allocating millions of data > stru

Re: [go-nuts] A question about copying

2020-07-25 Thread Jan Mercl
On Sat, Jul 25, 2020 at 10:09 AM chri...@surlykke.dk wrote: > Is this something I should have deduced from the language spec? https://golang.org/ref/spec#Address_operators For an operand x of type T, the address operation &x generates a pointer of type *T to x. The operand must be addressa

[go-nuts] CGo-free SQLite database/sql driver for linux/amd64 v1.4.0-beta1 is released

2020-07-26 Thread Jan Mercl
(reddit X-post) >From the change log at https://godoc.org/modernc.org/sqlite#hdr-Changelog 2020-07-26 v1.4.0-beta1: The project has reached beta status while supporting linux/amd64 only at the moment. The 'extraquick' Tcl testsuite reports 630 errors out of 200177 tests on Linux 64-bit

Re: [go-nuts] In the smippet herunder, are strings copied or passed by address (they seem copied, but maybe only the addresses are copied) ?

2020-08-01 Thread Jan Mercl
Please post code as just text. Also, inverted color schemes are hard to read for some people. Wrt string copying, see https://research.swtch.com/godata to;dr Copying a string copies two machine words. On Sat, Aug 1, 2020, 16:49 Serge Hulne wrote: > ``` > package main > > import ( > "fmt" >

Re: [go-nuts] Is it possible to build without TLS (thread local storage)?

2020-08-01 Thread Jan Mercl
Not sure I understand correctly, but TLS is usually provided on some level by the kernel of the specific OS. Another level is TLS as in, for example pthreads. The Go runtime probably uses one or the other additionally to goroutine local storage. Can you please clarify? On Sat, Aug 1, 2020, 20:08

Re: [go-nuts] A few thoughts on type parameters

2020-08-05 Thread Jan Mercl
On Tue, Aug 4, 2020 at 6:07 AM 'Carla Pfaff' via golang-nuts wrote: > On Tuesday, 4 August 2020 at 00:34:12 UTC+2 ben...@gmail.com wrote: > I'm sure it would quickly become a well-known idiom, just like people know > that "error" is "interface{Error() string}" or "fmt.Stringer" is > "interface

Re: [go-nuts] A few thoughts on type parameters

2020-08-05 Thread Jan Mercl
On Wed, Aug 5, 2020, 19:39 Tyler Compton wrote: > On Wed, Aug 5, 2020 at 1:07 AM Jan Mercl <0xj...@gmail.com> wrote: > >> It's not supposed to be anything special whatsoever. Just like number >> zero or an empty set is not some kind of an exception. It's just

Re: [go-nuts] Assigning byte to string location is not allowed

2020-08-13 Thread Jan Mercl
On Thu, Aug 13, 2020 at 3:02 PM Sathish VJ wrote: > Why is this not allowed? > > s := "hello" > s[0] = 'a' // compile error: cannot assign to s[0] > > https://play.golang.org/p/zyJXwhEeKPo Strings are immutable: once created, it is impossible to change the contents of a string.

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

2020-08-13 Thread Jan Mercl
On Thu, Aug 13, 2020 at 3:53 PM xie cui wrote: > ..., i know this type struct in generate by compiler, and i need to know > where is this code, and how to generate the struct fields and methods? To avoid the possibility of the XY problem, can you please tell more about the goal of "generating s

Re: [go-nuts] module confusion

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

Re: [go-nuts] Memory synchronization by channel operations and mutexes

2020-08-17 Thread Jan Mercl
On Mon, Aug 17, 2020 at 12:55 PM leo.b...@npo-data.nl wrote: > Thanks. So I take it this must be handled by the compiler when generating > assembly. > > I have peeked in the src/cmd/compile/ directory , assuming it is hidden > there, but that's a rabbit hole I do want to go in just yet. > > Wha

Re: [go-nuts] [generics] Type list syntax

2020-08-18 Thread Jan Mercl
On Tue, Aug 18, 2020 at 4:38 PM Frederik Zipp wrote: > The draft syntax for type lists is a comma separated list: > > type SignedInteger interface { > type int, int8, int16, int32, int64 > } > > Wouldn't it be more consistent with existing Go syntax regarding types if it > was a semi

Re: [go-nuts] How to find repeated string?

2020-08-19 Thread Jan Mercl
On Wed, Aug 19, 2020 at 10:07 AM 洪嘉鴻 wrote: > Hello everyone: > I use golang with Win10. The version of golang which I'm using is go1.15. > I want to find out the repeated string. > For example, given a string which is "1134534534534534". > I want the output string to be "345" > I've tried to > C

Re: [go-nuts] [ generics] Moving forward with the generics design draft

2020-08-20 Thread Jan Mercl
On Fri, Aug 21, 2020 at 2:28 AM Ian Lance Taylor wrote: > To simplify the common case of a type parameter that has > no constraints, we will introduce a new predeclared identifier “any” > as an alias for “interface{}”. Anyone can write the declaration type any = interface{} today and p

<    4   5   6   7   8   9   10   11   12   13   >