Re: [go-nuts] Using a defer func() closure to call c.free

2018-10-11 Thread Jan Mercl
On Thu, Oct 11, 2018 at 10:15 AM wrote: > What I am wondering is why the closure approach does not work? ISTM it should work. Please post a full, standalone reproduction code here or at the issue tracker, thanks. -- -j -- You received this message because you are subscribed to the Google

Re: [go-nuts] [ANN] astiencoder: an open source video encoder written in GO and based on ffmpeg C bindings

2018-10-09 Thread Jan Mercl
On Tue, Oct 9, 2018 at 10:31 AM Asticode wrote: > I'm happy to announce go-astiencoder, an open source video encoder written in GO and based on ffmpeg C bindings: https://github.com/asticode/go-astiencoder Three separate announcements of the same thing in cca 20 minutes. -- -j -- You

Re: [go-nuts] Strange behavior of range over composite literal.

2018-10-08 Thread Jan Mercl
On Mon, Oct 8, 2018 at 9:10 PM Raffaele Sena wrote: See https://golang.org/ref/spec#Composite_literals A parsing ambiguity arises when a composite literal using the TypeName form of the LiteralType appears as an operand between the keyword and the opening

Re: [go-nuts] go:nosplit

2018-10-08 Thread Jan Mercl
On Mon, Oct 8, 2018 at 1:50 PM Scott Cotton wrote: > However, I wanted to state that if the language doesn't specify this, and the language also doesn't specify what sys-calls are used on what platforms in what circumstances, then one can readily conclude that any Go program that relies on

Re: [go-nuts] What's the difference between local variables and fields when it comes to ignoring errors?

2018-10-02 Thread Jan Mercl
On Tue, Oct 2, 2018 at 3:29 PM wrote: > This code is allowed: > newlocalvar, _ := strconv.Atoi(somestring) > > And this code is forbidden: > somestruct.field, _ = strconv.Atoi(somestring) It is not forbidden: https://play.golang.org/p/YYUWhcNtPQB -- -j -- You received this message because

Re: [go-nuts] Huge map[string]*Object and GC where *Object is from sync.Pool

2018-09-28 Thread Jan Mercl
On Fri, Sep 28, 2018 at 2:53 PM Henrik Johansson wrote: > The data pointed to by the uintptrs ... Uintptrs are integers. They do not point to anything. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and

Re: [go-nuts] [ANN] go-formal github organisation

2018-09-27 Thread Jan Mercl
On Thu, Sep 27, 2018 at 11:38 AM Scott Cotton wrote: > I've just created a github organisation for formal tools in and for Go. Please expand on what a 'formal tool' is. I have no idea. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group.

Re: [go-nuts] Perf : Multithreaded goroutines files I/O

2018-09-16 Thread Jan Mercl
On Sun, Sep 16, 2018 at 2:09 PM Thomas Solignac wrote: > I tried loading with goroutines and without, and I get substantially the same process time (38s). The I/O speed of the disk device as well of the interface it's connected to is finitie. Throwing more goroutines at the task can have a

Re: [go-nuts] Periodic task when time.Ticker and time.Sleep are pretty expensive

2018-09-16 Thread Jan Mercl
On Sun, Sep 16, 2018 at 10:49 AM Lei Ni wrote: func main() { ... for { select { case <-ticker.C: // call my function here } } } Is the above the actual code you're using for the CPU usage "benchmark"?

Re: [go-nuts] variables name and scope

2018-09-13 Thread Jan Mercl
On Thu, Sep 13, 2018 at 3:42 PM wrote: > Why Go accepts to have différents variables with the same name ? Is there any good reasons ? Because Go is a block scoped language like C and others: https://en.wikipedia.org/wiki/Scope_(computer_science)#Block_scope -- -j -- You received this

Re: [go-nuts] SQL Interceptor

2018-09-10 Thread Jan Mercl
On Mon, Sep 10, 2018 at 8:16 AM Conrad Wood wrote: > Wdyt? Is that a patch that would be acceptable and generally useful? It could be tried and evaluated first as an external package. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group.

Re: [go-nuts] Re: Opening brace can't be placed on a separate line killing the language for me

2018-09-08 Thread Jan Mercl
On Sat, Sep 8, 2018 at 12:01 PM Mark Volkmann wrote: > How did you do that? I don’t see any formatting configuration. Correct, there's none. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

Re: [go-nuts] Opening brace can't be placed on a separate line killing the language for me

2018-09-08 Thread Jan Mercl
On Sat, Sep 8, 2018 at 10:09 AM wrote: > For me the language is Dead now it was a wasted time Don't blame the language. It's used by many programmers in many companies. Even big ones. Like Google, for example. Programming is one of the professions where continuous learning of new things and

Re: [go-nuts] Re: Opening brace can't be placed on a separate line killing the language for me

2018-09-08 Thread Jan Mercl
On Sat, Sep 8, 2018 at 10:14 AM Dave Cheney wrote: > I personally don't like that I cannot write one liner functions on one line because of gofmt's preference for reformatting the same function over three lines ... Please navigate to https://play.golang.org/p/VPfFLIyhUqp and click format. --

Re: [go-nuts] Why can't we use unicode? [Go2 Generics]

2018-09-07 Thread Jan Mercl
On Fri, Sep 7, 2018 at 6:29 PM roger peppe wrote: > In acme (and plan 9 generally), there's a nice set of mnemonic > abbreviations for unicode characters. > It's great, and I miss it in other environments. Alt-<< and Alt->> > work really well for « and » for example. > Here's the full list: >

Re: [go-nuts] how to convert big.Float to big.Int

2018-09-07 Thread Jan Mercl
On Fri, Sep 7, 2018 at 12:51 PM Shiming Liu wrote: > Hi you guys, do you know how to convert big.Float to big.Int, I have searched with google and searched in this group, but don't found valuable info. (*big.Float) Int() does that: https://golang.org/pkg/math/big/#Float.Int -- -j -- You

Re: [go-nuts] Why can't we use < > for the Go generic parameters ?

2018-09-06 Thread Jan Mercl
On Thu, Sep 6, 2018, 23:03 jimmy frasche wrote: > Wouldn't there be an issue with fp := AFunc[int] ? > > Though for that matter I wouldn't mind if the type part were repeated > for instantiations like AFunc[type int] or even AFunc(type int) > > For that matter, always writing type would let you

Re: [go-nuts] Why can't we use < > for the Go generic parameters ?

2018-09-06 Thread Jan Mercl
On Thu, Sep 6, 2018 at 9:49 AM Christophe Meessen < christophe.mees...@gmail.com> wrote: func f(bool) { ... } func g() { f(ad) } an similar constructs require unlimited look ahead to distinguish the above example from something generics. The current Go parser can always decide where to go based

Re: [go-nuts] Space-optimization question

2018-09-05 Thread Jan Mercl
On Wed, Sep 5, 2018 at 4:23 PM Eric Raymond wrote: > Matters in my case because the deserialization of a repository history can contain hundreds of thousands of constants like "M", "D", "R", and "C" > representing fast-export stream file operation types. I could intern them explicitly but it

Re: [go-nuts] Space-optimization question

2018-09-05 Thread Jan Mercl
On Wed, Sep 5, 2018 at 4:00 PM Eric Raymond wrote: > If I have multiple occurrences of a string constant in source code - say, "M" - can I count on the compiler to create one static instance and pass references to it everywhere? It's unspecified, so strictly speaking you cannot. (Also,

Re: [go-nuts] Re: Taking possible EOF as input

2018-09-04 Thread Jan Mercl
On Tue, Sep 4, 2018 at 5:28 PM Hunter Breathat wrote: > I only had stated that bufio.Scan() doesn't return io.EOF as the doc stats that it Err returns nil. Which is fine but hard to check for. But from what I've seen the functionality that im looking for would need to check for the SIG.KILL/EOF

Re: [go-nuts] Reference to type satisfying a specified interface

2018-09-04 Thread Jan Mercl
On Tue, Sep 4, 2018 at 1:05 PM Eric Raymond wrote: > For me personally this is a relatively minor problem - not my first rodeo of this kind nor even my dozenth, I have broad experience and know how to adapt and persist. > For most newbies it's going to be a serious blocker. I can recommend a

Re: [go-nuts] Determining memory use of structs containing slices

2018-09-04 Thread Jan Mercl
On Tue, Sep 4, 2018 at 10:29 AM Ingo Jaeckel wrote: > It seems the length of a slice is not considered by unsafe.SizeOf . Rightfully so. The size of a slice is a compile-time constant. > I assume this is a side effect of .SizeOf being evaluated at compile

Re: [go-nuts] Are Go floats smarter?

2018-09-02 Thread Jan Mercl
On Sun, Sep 2, 2018 at 4:24 PM Manlio Perillo wrote: > What happens if you need to divide 7 pennies by 4? > Using integers will result in 1, and this is probably not what you want, if this result needs to be used in further calculations. > > For financial applications you should use decimal

Re: [go-nuts] Some background on reposurgeon and my Go translation problem

2018-08-31 Thread Jan Mercl
On Fri, Aug 31, 2018 at 11:48 AM Eric Raymond wrote: > I did experiment with that. Unfortunately, the source code it produced when I ran it on my stuff was an unmaintainable mess. > Possibly correct, I don't know - but I couldn't trust it because I can't read it. Yup, not surprising considering

Re: [go-nuts] Some background on reposurgeon and my Go translation problem

2018-08-31 Thread Jan Mercl
On Fri, Aug 31, 2018 at 10:29 AM Jan Mercl <0xj...@gmail.com> wrote: > https://opensource.googleblog.com/2017/01/grumpy-go-running-python.html. The linked above blog post links to http://grump.io/ but it seems to be a dead link for me ATM. The project repository is here: https://g

Re: [go-nuts] Some background on reposurgeon and my Go translation problem

2018-08-31 Thread Jan Mercl
On Fri, Aug 31, 2018 at 5:43 AM Eric Raymond wrote: > I translated an auxiliary tool called repocutter (it slices and dices Subversion dump streams) as a warm-up. This leads me to believe I can expect about a 40x speedup. > That's worth playing for, even before I do things like exploiting

Re: [go-nuts] Reference to type satisfying a specified interface

2018-08-30 Thread Jan Mercl
On Thu, Aug 30, 2018, 18:57 Eric Raymond wrote: > I apologize if this seems like an elementary question, but web searches > and reading the Go documentation is not turning up an answer. > > I'm in the process of translating reposurgeon, an editor for > version-control histories, from Python into

Re: [go-nuts] Re: Regarding string immutablity

2018-08-28 Thread Jan Mercl
On Tue, Aug 28, 2018 at 6:45 PM Jay Sharma wrote: > @Jan, The example you shown it is copying a string to new variable. but my question was related to same variable. > Will it overwrite the same memory or it will create some copy ? The same concept applies as before. String variables are

Re: [go-nuts] Regarding string immutablity

2018-08-28 Thread Jan Mercl
On Tue, Aug 28, 2018 at 4:55 PM Jay Sharma wrote: > As I am overwriting the content with new content, Is it inplace replacement [same memory is being updated] or a new copy will be created with new content and old content will be there in the memory ? Basically none of that. Strings indeed are

Re: [go-nuts] What is the proper way to delete a key which holding a pointer in a map

2018-08-27 Thread Jan Mercl
On Mon, Aug 27, 2018 at 11:38 AM Kasun Vithanage wrote: > I simply want to delete the memory allocated by Value too. When i checked memory with MemStats, its still same as when i added entries to map See https://github.com/golang/go/issues/20135#issuecomment-297490415 "The only available

Re: [go-nuts] function's argument default value

2018-08-22 Thread Jan Mercl
On Wed, Aug 22, 2018 at 3:20 PM Masoud Ghorbani wrote: > In my description, I used the argument title instead parameter, sorry for this confusion. Now I'm lost in translation ;-) Can you please show some code illustrating the topic? Like code written now vs code written while feature X would be

Re: [go-nuts] function's argument default value

2018-08-22 Thread Jan Mercl
On Wed, Aug 22, 2018 at 2:39 PM Masoud Ghorbani wrote: > Why there isn't function argument default value in Golang explicitly like Typescript and Python? What are the possible benefits? The only things that come to my mind are IMO negative. The definition of the default value is in a different

Re: [go-nuts] help with using crc32.Update for BE data.

2018-08-22 Thread Jan Mercl
On Wed, Aug 22, 2018 at 7:23 AM Dan Kortschak wrote: > https://stackoverflow.com/questions/51960305/convert-crc32-sum-from- lsb-first-algorithm-to-sum-for-msb-first-algorithm

Re: [go-nuts] Re: Garbage collector and Slices

2018-08-20 Thread Jan Mercl
On Mon, Aug 20, 2018 at 3:48 PM 'Florian Uekermann' via golang-nuts < golang-nuts@googlegroups.com> wrote: >> The garbage collector does not care about the values of items of a []T when T is not a pointer type nor a type containing transitively any pointers. > > Just to make sure I understand

Re: [go-nuts] Re: Garbage collector and Slices

2018-08-20 Thread Jan Mercl
On Mon, Aug 20, 2018 at 2:49 PM 'Florian Uekermann' via golang-nuts < golang-nuts@googlegroups.com> wrote: > ... which would put unnecessary strain on the GC iirc, because the memory pointed to would be scanned conservatively (basically assuming everything in there could be a pointer). The

Re: [go-nuts] GO lang implementation for one deck card shuffle

2018-08-17 Thread Jan Mercl
On Fri, Aug 17, 2018 at 1:09 PM Sokolov Yura wrote: > I'd recently made "practically secure rng": https://github.com/funny-falcon/go-rando > > It uses SipHash permutation core (so it has 256 bit permuation stsate + counters), but also constantly reseeded from 1024 bit "entropy pool" that is

Re: [go-nuts] Decoding the buffer to a struct sent from C program

2018-08-16 Thread Jan Mercl
On Thu, Aug 16, 2018 at 5:29 AM wrote: > char str[384]; > Str [384]string The counterpart to C.char is uint8 aka byte. IOW struct foo { char bar[42]; } corresponds to type foo struct { bar [42]byte } -- -j -- You received this message because you are subscribed to the

Re: [go-nuts] Why "strings" package exists ?

2018-08-16 Thread Jan Mercl
On Thu, Aug 16, 2018 at 6:53 AM Kevin Malachowski wrote: > Well, the 'error' type has a method. But none of the other primitives do. The predeclared 'error' type is an interface. Interfaces do not have methods. Interfaces only declare method sets. -- -j -- You received this message because

Re: [go-nuts] no reply after writing data on TLS connection

2018-08-10 Thread Jan Mercl
On Fri, Aug 10, 2018 at 12:21 PM Alan Lu wrote: What's wrong? IDK, but possibly related: https://downforeveryoneorjustme.com/gp-cq9.tgpaccess.com -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

Re: [go-nuts] filepath.WalkFunc documentation question

2018-08-10 Thread Jan Mercl
On Fri, Aug 10, 2018 at 10:24 AM wrote: > Is this intentional or incorrect documentation ? The reason is that the resulting filename is produced by Join which Cleans the result. This should be perhaps added to the documentation. -- -j -- You received this message because you are subscribed

Re: [go-nuts] How to update packages without duplicating distro packages

2018-08-08 Thread Jan Mercl
On Wed, Aug 8, 2018 at 1:40 PM Kevin Locke wrote: > In my initial email $GOPATH was unset. Then I would try (unset $GOPATH defaults to being effectively the same as $HOME/go on nix) $ cd $HOME/go/src ; go get -u ./... (add -v and/or -x to see if something is actually happening) -- -j --

Re: [go-nuts] How to update packages without duplicating distro packages

2018-08-08 Thread Jan Mercl
On Mon, Aug 6, 2018 at 6:12 AM Kevin Locke wrote: > Is there a way to update packages installed using `go get` without > duplicating packages that are distributed with Go or by my Linux > distribution? Assuming your $GOPATH is something like : $ cd /src; go get -u ./... -- -j -- You

Re: [go-nuts] Re: Nil Channels and Case Evaluation

2018-08-08 Thread Jan Mercl
On Wed, Aug 8, 2018 at 11:15 AM Kaveh Shahbazian wrote: > But the error message (no cases) is confusing and unclear because obviously there is a case there. I don't think it's confusing. The run-time message obviously does not talk about the compile-time case presence but about no case the

Re: [go-nuts] CGO-How to access C struct pointer correctly

2018-08-07 Thread Jan Mercl
On Tue, Aug 7, 2018 at 2:42 PM 陈一剑 wrote: > I want to print 333,but the result is strange. The answer is provided by the compiler itself: jnml@r550:~/src/tmp> cat main.go package main import ( "fmt" /* struct Test{ int ID; }; struct Test * test(){ struct Test test;

Re: [go-nuts] Re: Possible missing atomic load(s)/store(s) in runtime/chan.go?

2018-08-05 Thread Jan Mercl
On Sun, Aug 5, 2018 at 9:01 PM Marvin Stenger wrote: > What: Code path protected by a mutex > Does what: does not execute concurrently > Surely it can execute concurrently, and even in parallel if your machine has more than one core. Then we are using the same word for different meanings,

Re: [go-nuts] Re: Possible missing atomic load(s)/store(s) in runtime/chan.go?

2018-08-05 Thread Jan Mercl
On Sun, Aug 5, 2018 at 8:25 PM Marvin Stenger wrote: > Well it does. Does what? Even, what does what? > For this this case of chan.go there are multiple reasons working together, why it is ok to sometimes use a lock, othertimes only atomic access or even plain access: Maybe I misunderstand

Re: [go-nuts] Re: Possible missing atomic load(s)/store(s) in runtime/chan.go?

2018-08-05 Thread Jan Mercl
On Sun, Aug 5, 2018 at 7:28 PM wrote: > It is also my understanding that writes within a locked region that are read in some fast path without holding the lock need to be atomic writes. And the write to c.closed in closechan is NOT atomic. Code path protected by a mutex does nor execute

Re: [go-nuts] CGO - convert a c.char array to string

2018-08-05 Thread Jan Mercl
On Sun, Aug 5, 2018 at 2:50 PM nicolas_boiteux via golang-nuts < golang-nuts@googlegroups.com> wrote: > not sure to understand cause the iteration in your example is done on os interface from golang not from c char array :( Not sure what you mean by 'os interface'. Here's the part that iterates

Re: [go-nuts] CGO - convert a c.char array to string

2018-08-05 Thread Jan Mercl
On Sun, Aug 5, 2018 at 12:29 PM nicolas_boiteux via golang-nuts < golang-nuts@googlegroups.com> wrote: > it returns : > > .\armago_x64.go:19: cannot convert p (type **_Ctype_char) to type uintptr Ok, this time bit more tested jnml@4670:~/tmp> cat main.c #include int main(int argc, char

Re: [go-nuts] CGO - convert a c.char array to string

2018-08-05 Thread Jan Mercl
On Sun, Aug 5, 2018 at 12:05 PM nicolas_boiteux via golang-nuts < golang-nuts@googlegroups.com> wrote: > Do you know a standard method to iterate & convert all the argv array in one golang string array ? Something like (not tested): var a []string for p := argv; *p != nil; p =

Re: [go-nuts] time.Now takes ~3758 ns/op, is that normal?

2018-05-24 Thread Jan Mercl
On Thu, May 24, 2018 at 10:08 AM wrote: > So, I want to know is that normal to be this slow? I think it's not normal. jnml@r550:~/src/tmp> cat x_test.go package main import ( "testing" "time" ) func BenchmarkTimeNow(b *testing.B) { for i := 0; i < b.N; i++ { time.Now() } }

Re: [go-nuts] SUSE LINUX ( s390x-linux-gnu-gcc )

2018-05-23 Thread Jan Mercl
On Wed, May 23, 2018 at 2:49 PM Sreekanth G wrote: Hi, I have install GoLang on Suse Linux on IBM cloud. go version is go1.10.2 linux/s390x > go path is > export PATH=$PATH:/usr/local/go/bin Note: That's PATH, not GOPATH. > export GOROOT=$HOME/go1.X > > export

Re: [go-nuts] Go type syntax

2018-05-23 Thread Jan Mercl
On Wed, May 23, 2018 at 12:15 PM Lucio wrote: > I can't believe I've overlooked this "feature" in the documentation. Introduced in Go 1.9: https://golang.org/doc/go1.9#language -- -j -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] add Printfln to log and fmt

2018-05-23 Thread Jan Mercl
On Wed, May 23, 2018 at 1:29 AM wrote: > Is there an inbuilt library function that does this? There's not. However note that the log package adds the final \n automatically to every output not already having it. -- -j -- You received this message because you are

Re: [go-nuts] Performance hit when using goroutine

2018-05-22 Thread Jan Mercl
On Tue, May 22, 2018 at 7:12 AM Hawari Rahman wrote: > Is there something that I need to address in the previous code snippet? It's necessary to analyze and understand the code to figure out if adding concurrency makes sense. Just running many tasks in goroutines does

Re: [go-nuts] C.malloc of Go type?

2018-05-19 Thread Jan Mercl
On Sat, May 19, 2018 at 10:42 PM Max wrote: > The question is: is it allowed to take the unsafe.Pointer returned by C.malloc() and convert it to a pointer to a Go struct type? See https://golang.org/pkg/unsafe/#Pointer -- -j -- You received this message

Re: [go-nuts] dynamic programming or something else

2018-05-15 Thread Jan Mercl
On Tue, May 15, 2018 at 2:23 AM Alex Dvoretskiy wrote: > I'm trying to solve a problem. Algorithm is correct, but too slow. Perhaps you can give me some ideas on how to improve running time? Fib() is fun:

Re: [go-nuts] Digest for golang-nuts@googlegroups.com - 18 updates in 9 topics

2018-05-14 Thread Jan Mercl
On Mon, May 14, 2018 at 5:33 AM Pete Wilson wrote: > And then the quality of software will improve, because not everybody can afford a few billion Depends on how you define quality. Catch: bug-free is not a usable definition of software quality. At least while humans

Re: [go-nuts] Writing a Compiler for Web Assembly

2018-05-11 Thread Jan Mercl
On Fri, May 11, 2018 at 1:59 PM Chris FractalBach wrote: > Is there a main discussion for making "Go To Web Assembly" ? =) Here's the issue: https://github.com/golang/go/issues/18892 Progress can be seen eg. here:

Re: [go-nuts] Re: Go could really use a while statement

2018-05-11 Thread Jan Mercl
On Fri, May 11, 2018 at 12:28 PM Louki Sumirniy < louki.sumirniy.stal...@gmail.com> wrote: > I strongly dispute whether forcing a single statement in a block to be on a new line benefits readability. Fun fact: The major point of gofmt is to bring endless and pointless code formatting disputes to

Re: [go-nuts] Re: Go could really use a while statement

2018-05-11 Thread Jan Mercl
On Fri, May 11, 2018 at 10:22 AM Louki Sumirniy < louki.sumirniy.stal...@gmail.com> wrote: > On that note, I think that most of the ways that gofmt changes things is nice but I think I'm disabling its use from now on because more than a few times I have seen my line count expanded massively >

Re: [go-nuts] Bug or not?

2018-05-10 Thread Jan Mercl
On Thu, May 10, 2018 at 1:00 PM roger peppe wrote: > "The scope of a type identifier declared inside a function begins at > the identifier in the TypeSpec and ends at the end of the innermost > containing block." That's it, thanks. Got bitten by the difference wrt variable

[go-nuts] Bug or not?

2018-05-10 Thread Jan Mercl
This modified example from another thread does not compile: package main import ( "fmt" ) type T int func main() { var v T type T *T var w T w = *w = v

Re: [go-nuts] Cyclic types

2018-05-10 Thread Jan Mercl
On Wed, May 9, 2018 at 7:45 PM Robert Griesemer wrote: > PS: Here's an example where we (humans) can obviously compute the size of a type, yet neither cmd/compile, gccgo, nor go/types have any success in doing so: > > type T struct { > a [10]int > b

Re: [go-nuts] Cyclic types

2018-05-10 Thread Jan Mercl
On Wed, May 9, 2018 at 7:01 PM Robert Griesemer wrote: > I think we also have been hesitant to simply disallow "cyclical types" (per your definition of cyclical) in the spec because we (or at least I) don't have a good understanding that our code actually detects exactly those.

[go-nuts] Cyclic types

2018-05-09 Thread Jan Mercl
Robert Griesemer wrote in https://github.com/golang/go/issues/25305#issuecomment-387624488 at May 9th: I'm probably using incorrect assumptions. Let me summarize them here: 1) A type is cyclical iff its size is not computable. I'm really not sure if this is what the specification really

Re: [go-nuts] Re: go 1 on Ubuntu 18.04

2018-05-08 Thread Jan Mercl
On Tue, May 8, 2018 at 9:43 AM Dave Cheney wrote: > Please allow me to clarify, anyone other than Jan never needs to set GOROOT. In the absence of the proof to the contrary, please let me note that the above quoted is not correct ;-) -- -j -- You received this message

Re: [go-nuts] Re: go 1 on Ubuntu 18.04

2018-05-08 Thread Jan Mercl
On Mon, May 7, 2018 at 10:02 PM Dave Cheney wrote: > Top tip: you never need to set GOROOT. Please don’t set GOROOT, it’ll just cause confusing errors for you in the future. The formulation quoted above is not correct because of the word 'never'. Most people do not need to ever

Re: [go-nuts] I don't know about callbacks in Golang

2018-05-07 Thread Jan Mercl
On Sat, May 5, 2018 at 2:52 AM Eduardo Moseis Fuentes wrote: > HI everyone I´m Eduardo from Guatemala and I'm beginer. I'm interesting in all scope golang in fact I was download a little book about it, but I need learn more about callbacks because the book don´t has > enough

Re: [go-nuts] Re: fallthrough for select

2018-05-06 Thread Jan Mercl
On Sun, May 6, 2018 at 6:34 AM wrote: > ... I feel like any kind of switch-like statements should be able to fallthrough. switch x := f.(type) { case *Foo: ... falthrough case *Bar: x.Baz() // <-

Re: [go-nuts] Implementing method overloading using first class functions

2018-05-03 Thread Jan Mercl
On Thu, May 3, 2018 at 10:14 PM Louki Sumirniy < louki.sumirniy.stal...@gmail.com> wrote: > As some here may know, I am implementing a novel binary tree based on complete trees and using ideas from B-heaps in order to achieve maximum data cache locality in a search and sort algorithm. ... >

Re: [go-nuts] proposal: embed static assets

2018-05-02 Thread Jan Mercl
On Wed, May 2, 2018 at 9:23 PM Manlio Perillo wrote: > Note that you can load assets of any package, not only of the "current" package. No doubt that's useful, but the topic of this thread is about embedded, static assets, fixed at link time. -- -j -- You received

Re: [go-nuts] proposal: embed static assets

2018-05-02 Thread Jan Mercl
On Wed, May 2, 2018 at 8:31 PM Manlio Perillo wrote: > The interface is different. > > Open(pkg, path string) ... Please explain why the 'pkg' argument is needed. Paths can encode any hierarchy. > You also need the package import path to load an asset. I do not

Re: [go-nuts] proposal: embed static assets

2018-05-02 Thread Jan Mercl
On Wed, May 2, 2018 at 7:39 PM Manlio Perillo wrote: > type Asset interface bike shedding: type Assets = http.FileSystem -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

Re: [go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Jan Mercl
On Wed, May 2, 2018 at 5:16 PM Tong Sun wrote: Ugly hack, completely wrong in the general case: https://play.golang.org/p/IM_lxT3PxmR -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group

Re: [go-nuts] Go could really use a while statement

2018-05-02 Thread Jan Mercl
On Wed, May 2, 2018 at 11:34 AM Lutz Horn wrote: > You can even write > for true { > } > > to get an infinite loop you will have to break from. for { } works just as well: https://play.golang.org/p/aEkbUjLmf_T -- -j -- You received this message because you are

Re: [go-nuts] Question about int inside json

2018-04-29 Thread Jan Mercl
On Sun, Apr 29, 2018 at 5:52 AM wrote: > Almost every documentation I've found says int is 32 bit long, so that I expect a range from -2.147.483.648 to 2.147.483.647. Can you please share an example of such incorrect documentation? -- -j -- You received this message

Re: [go-nuts] Beginner question about interface

2018-04-28 Thread Jan Mercl
On Sat, Apr 28, 2018 at 8:56 AM wrote: > I want to search in all library (which have source code) If the above means the standard library: either local godoc search or https://golang.org/search?q=Read. But as you can see, you'll get a vast amount of hits. > for exmaple : >

Re: [go-nuts] Beginner question about interface

2018-04-28 Thread Jan Mercl
The answer depends on the scope you want to search. Which scope you want to search? Also, please share what purpose does that information serve. I cannot imagine a one. On Sat, Apr 28, 2018, 07:06 wrote: > Hi > > How can i get a list of types which implement a particular

Re: [go-nuts] How does time reported by go test relate to the wall clock time?

2018-04-27 Thread Jan Mercl
On Fri, Apr 27, 2018 at 8:36 AM Jan Mercl <0xj...@gmail.com> wrote: > Above we can see the reported 6.7 seconds are in both cases the time to execute the test binary per se. Additional 2.1 seconds were spent in producing the binary. s/6.7/9.6/ -- -j -- You received this message be

Re: [go-nuts] How does time reported by go test relate to the wall clock time?

2018-04-27 Thread Jan Mercl
On Fri, Apr 27, 2018 at 8:17 AM Prateek Rungta wrote: > Would people be opposed to changing that behavior? I guess so. > I’ve always thought of the time returned as the time to execute the command. Doesn’t matter to me if it’s having to compile or not. The use the time

Re: [go-nuts] How does time reported by go test relate to the wall clock time?

2018-04-26 Thread Jan Mercl
time reports build+test time, but go test reports only test time. On Thu, Apr 26, 2018, 18:54 Prateek Rungta wrote: > I've noticed weird discrepancies in the time reported by `go test > `, and the elapsed wall clock time. > > For example: > > ❯ time go test ./client > ok

Re: [go-nuts] Type func binding and interfaces

2018-04-23 Thread Jan Mercl
On Mon, Apr 23, 2018 at 8:58 PM Louki Sumirniy < louki.sumirniy.stal...@gmail.com> wrote: > The type function bindings are not the problem, the problem is the fact that despite in every other way the signatures match, they will not be found by the compiler to bind to the type, and thus the need

Re: [go-nuts] Re: Why not tuples?

2018-04-19 Thread Jan Mercl
On Thu, Apr 19, 2018 at 2:51 PM Louki Sumirniy < louki.sumirniy.stal...@gmail.com> wrote: > Sorry for the self-promotion but it was relevant in that I was working on how to tidy up the readability of my code and needed multiple returns and simple untyped tuples were really not nearly as

Re: [go-nuts] go get -tags

2018-04-19 Thread Jan Mercl
On Thu, Apr 19, 2018 at 2:29 PM Kaveh Shahbazian wrote: > How does go get -tags work? `go get -tags foo example.com/bar` should be similar, but not always equal to `go get -d example.com/bar && go install -tags foo example.com/bar`. -- -j -- You received this

Re: [go-nuts] Fancy Comments & Documentation

2018-04-19 Thread Jan Mercl
On Thu, Apr 19, 2018 at 7:37 AM Chris FractalBach wrote: > However, adding comments like this into Go code often ruins the documentation, so I have been avoiding it. Please specify what do you mean by "ruins the documentation". Do you have an example that can be already

Re: [go-nuts] Re: Why not tuples?

2018-04-18 Thread Jan Mercl
On Thu, Apr 19, 2018 at 6:57 AM Louki Sumirniy < louki.sumirniy.stal...@gmail.com> wrote: > > func (b *Bast) Parent(c Cursor) Cursor { > if c.Index == 0 { > c.Err = errors.New("No parent from the root") > return c > } > c.Row-- > c.Index = c.Index>>1 - (c.Index+1)%2 > c.Err = nil > return c > } >

Re: [go-nuts] Extension for type assertion of interface array

2018-04-18 Thread Jan Mercl
On Wed, Apr 18, 2018 at 4:22 PM Jan Mercl <0xj...@gmail.com> wrote: > On Wed, Apr 18, 2018 at 4:13 PM <nsakth...@gmail.com> wrote: > > When possible, avoid using '[]interface{}' and use just 'interface{}' > instead: https://play.golang.org/p/oPtPoGChkMZ. > > >

Re: [go-nuts] Extension for type assertion of interface array

2018-04-18 Thread Jan Mercl
On Wed, Apr 18, 2018 at 4:13 PM wrote: When possible, avoid using '[]interface{}' and use just 'interface{}' instead: https://play.golang.org/p/oPtPoGChkMZ. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] Usage example inside a lib project

2018-04-18 Thread Jan Mercl
On Wed, Apr 18, 2018 at 2:35 PM Federico Paolinelli wrote: See https://golang.org/pkg/testing/#hdr-Examples. Put the examples into the foo_test.go file. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] The Go code formatter

2018-04-18 Thread Jan Mercl
On Wed, Apr 18, 2018 at 1:24 PM Ali Altun wrote: > There is a code part in the https://golang.org/pkg/sort/#example_ > The Go code formatter doesn't change this code. The code is already gofmt'ed, so no change is expected. > Similarly, how can I make it leave the

Re: [go-nuts] [NEWBIE] syncmap - how to use it correctly

2018-04-13 Thread Jan Mercl
On Fri, Apr 13, 2018 at 2:29 PM wrote: > What i do wrong? The code relies on the bool value in 'ok', returned from .Load(), but that _does not_ mean some other goroutine, once you remove the mutex.Lock(), cannot insert a value for the same key the moment the call of

Re: [go-nuts] [NEWBIE] what means importing a file versus a directory?

2018-04-11 Thread Jan Mercl
On Wed, Apr 11, 2018 at 3:21 PM Robert P. J. Day wrote: > ... -- what does it mean > to import a name that is a single .a file versus importing a directory > name from under GOROOT (in my case, on fedora, /usr/lib/golang). You mostly cannot really import a file and

Re: [go-nuts] alternate struct tags for json encode/decode?

2018-04-11 Thread Jan Mercl
On Wed, Apr 11, 2018 at 2:50 PM Reed Wade wrote: > Is there a sensible existing way to do that? Would this be a useful update to the lib? Not very nice, but: https://play.golang.org/p/gkWEuV1AlwB -- -j -- You received this message because you are subscribed to the

Re: [go-nuts] Sorting slice of structs

2018-04-10 Thread Jan Mercl
On Tue, Apr 10, 2018 at 8:29 PM Sankar wrote: > Any help on how I can get arr sorted in the above code ? Just a typo: https://play.golang.org/p/vhbo8OIrh-H -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group.

Re: [go-nuts] formatting question/issue

2018-04-10 Thread Jan Mercl
On Tue, Apr 10, 2018 at 1:32 AM Alex Dvoretskiy wrote: > Why there is no difference if the last comma exists? Because the language specification allows to omit the last comma before the closing '}': LiteralValue = "{" [ ElementList [ "," ] ] "}" . See:

Re: [go-nuts] Regexp: Matching a new line but *not* start of string, from a Reader

2018-04-09 Thread Jan Mercl
On Mon, Apr 9, 2018 at 4:37 PM Alex Efros wrote: > I've just tried it with strings.Reader and found current seek position > after FindReaderSubmatchIndex is in 3 bytes after end of the match: > https://play.golang.org/p/OJT7Ri8ji2C Maybe

Re: [go-nuts] Regexp: Matching a new line but *not* start of string, from a Reader

2018-04-09 Thread Jan Mercl
On Mon, Apr 9, 2018 at 6:47 AM Paul Lalonde wrote: > Any advice? If regexp cannot solve your task don't use regexp. Write the tiny state machine by yourself, it should be not too much code. -- -j -- You received this message because you are subscribed to the

Re: [go-nuts] Re: Is there a memory leak on Rob Pike's demo codes?

2018-04-05 Thread Jan Mercl
On Thu, Apr 5, 2018 at 9:10 AM T L wrote: > yes. it is a resource leak. It's not necessarily a leak. It's a possible leak. And digging even deeper: it's implementation defined. Non-reachable channels can be collected and goroutines blocked on them killed without changing

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