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

2019-04-25 Thread Jan Mercl
On Thu, Apr 25, 2019 at 8:58 PM wrote: > > Rob : how can it be abused if the compiler wont allow nested ? operators ?? Rather easily. Just by fuzzilly mixing the otherwise purposely distinct syntax of expressions and control flow. -- You received this message because you are subscribed to the

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

2019-04-24 Thread Jan Mercl
On Wed, Apr 24, 2019 at 3:05 AM wrote: > > It sure would be nice if Go syntax allowed programmers to replace > > if ( test) { > ...do sonething > } That's not how Go's if statement looks. Gofmt will remove the superficial parentheses around 'test'. Wrt the rest of the proposal, today, this is

Re: [go-nuts] cannot use CallBack (type func(*_Ctype_char, *_Ctype_char, _Ctype_ulong)) as type *[0]byte in argument to _Cfunc_reload_pattern_db

2019-04-24 Thread Jan Mercl
On Wed, Apr 24, 2019 at 10:47 AM Nitish Saboo wrote: > ./main.go:80:32: cannot use key (type *_Ctype_char) as type string in map > index func CallBack(ckey *C.char, value *C.char, value_len C.size_t){ key := C.GoString(ckey) if remap, ok := field_mappings[key]; ok {

Re: [go-nuts] cannot use CallBack (type func(*_Ctype_char, *_Ctype_char, _Ctype_ulong)) as type *[0]byte in argument to _Cfunc_reload_pattern_db

2019-04-24 Thread Jan Mercl
On Wed, Apr 24, 2019 at 1:51 PM Nitish Saboo wrote: > > Hi, > > I followed the link > 'https://github.com/golang/go/wiki/cgo#function-variables' and made the > following changes: > 1)main.go > package main > //#cgo CFLAGS: -I./syslog-ng-3.6.2/ > //#cgo LDFLAGS: syslog-node.so > //#cgo LDFLAGS:

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

2019-04-24 Thread Jan Mercl
On Wed, Apr 24, 2019 at 2:04 PM Mark Volkmann wrote: > The idea of adding the ternary operator to Go has been debated many times. > It’s clear that those in charge have a strong dislike for it. For me the lack > of the ternary operator is one of main things I dislike about Go. It’s nails > on

Re: [go-nuts] Pass value from C code to GO code(CGO)

2019-04-26 Thread Jan Mercl
On Fri, Apr 26, 2019 at 12:54 PM Nitish Saboo wrote: > Can I pass a pointer to a value from Go to C, do some manipulation on it > within the C code and access the value from Go after the C code executes ? The first part of the question is discussed in great detail here:

Re: [go-nuts] Pass value from C code to GO code(CGO)

2019-04-26 Thread Jan Mercl
On Fri, Apr 26, 2019 at 12:34 PM Nitish Saboo wrote: > > Hi, > > I want to call C code from GO code.Once the C code gets executed I want to > pass the value back to the GO code. > Can someone please guide me as in how to pass value back from C code to the > GO code. What C type the value is?

Re: [go-nuts] Question about iterator implementation of golang map

2019-07-15 Thread Jan Mercl
On Mon, Jul 15, 2019 at 4:39 PM Aaron Lau wrote: > We won't update the map during the traversal process. So why use mapaccessK > to find the k & v again ? The comment explains that very clearly: > // The hash table has grown since the iterator was started. > // The golden data for this key is

Re: [go-nuts] What is the fundamental unit of linking in Go?

2019-06-28 Thread Jan Mercl
Please provide a minimal, self contained demonstration code that reproduces the problem. Then it should be hopefully easy to either explain why things work they do or it'll be a nice test case for the fix to the issue this may actually be. Thanks. On Fri, Jun 28, 2019, 20:10 wrote: > I have

Re: [go-nuts] Counter-counter-counter proposals

2019-06-30 Thread Jan Mercl
On Mon, Jul 1, 2019 at 4:50 AM Michael Jones wrote: > ... language design is about other people and other use cases than your own. That nicely explains C++ existence. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this

Re: [go-nuts] for i := range

2019-08-16 Thread Jan Mercl
One ranges a copy of the array, the other does not: https://play.golang.org/p/Z3InmyFqQN3 On Fri, Aug 16, 2019, 19:11 Vadim Maximov wrote: > Hi, all! > > Is *for.*..*range* over an address/reference of an array faster than > regular *for...range*? For instance: > > arr :=[...]int{1,2,3} > for

Re: [go-nuts] Re: mutual exclusion algorithm of Dijkstra - strange behaviour

2019-08-16 Thread Jan Mercl
On Fri, Aug 16, 2019 at 8:09 PM wrote: > Meanwhile it is clear why things do not work: > The Go-Scheduler is unable to allow to switch to another goroutine in > busy-waiting-loops - > the only possibility to get around that problem is either to put > "switch-steps" into the source > - either

Re: [go-nuts] Re: When doing "type X Y", is it a type alias or type redefinition or type adapter or something else?

2019-08-13 Thread Jan Mercl
On Tue, Aug 13, 2019 at 9:24 AM Volker Dobler wrote: > Yes, of course. It declares a new named type X, the underlying > type is Y which can be some predeclared type like int, some > other named declared type (like MyFooType) or a "type literal" > (a term I made up) like struct{X,Y float64; T

Re: [go-nuts] Go string and UTF-8

2019-08-20 Thread Jan Mercl
On Tue, Aug 20, 2019 at 3:17 PM Pierre Durand wrote: > > Well, in my case I don't want to convert the []byte to hexadecimal string, > because it uses 2x more memory. > The code contains a huge map where the key is an MD5 hash. md5 hash is an array type and can be used as a map key directly:

Re: [go-nuts] How to execute a command using root?

2019-08-30 Thread Jan Mercl
On Fri, Aug 30, 2019 at 8:49 AM Benjamin wrote: >Do anyone have any suggestions on this? Thanks. IINM, what you want is not possible. Moreover, it should not be possible. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

Re: [go-nuts] How to execute a command using root?

2019-08-30 Thread Jan Mercl
On Fri, Aug 30, 2019 at 8:53 AM Jan Mercl <0xj...@gmail.com> wrote: > Moreover, it should not be possible. But whitelisting certain users to run certain programs using sudo, but no password, is possible. -- You received this message because you are subscribed to the Google Groups &qu

Re: [go-nuts] how to merge different struct to one struct

2019-08-23 Thread Jan Mercl
On Sat, Aug 24, 2019 at 5:25 AM Lee Rick wrote: > > i want to do > type A struct{ Name string} > type B struct{Age int} > type C struct{Address string} > > a, b, c := A{}, B{},C{} > have a function > d1 := merge(a,b) //d1 like struct{Name string, Age int} > d2 := merge(a,c) //d2 like

Re: [go-nuts] Re: v1.13: Altered go.mod file in project after updating vim-go binaries

2019-09-05 Thread Jan Mercl
On Thu, Sep 5, 2019 at 8:18 PM wrote: > Running 'go get ...' inside a module can add indirect dependencies to go.mod. I'm surprised. There's probably some rationale behind `go get` having such side effects. Can anyone please shed some light on this? -- You received this message because you

Re: [go-nuts] Re: v1.13: Altered go.mod file in project after updating vim-go binaries

2019-09-05 Thread Jan Mercl
On Thu, Sep 5, 2019 at 8:51 PM Mihai Borobocea wrote: > $ go help module-get > The 'go get' command changes behavior depending on whether the > go command is running in module-aware mode or legacy GOPATH mode. > … > Get resolves and adds dependencies to the current development module > and then

Re: [go-nuts] how to pass c array to golang efficiently

2019-08-07 Thread Jan Mercl
On Wed, Aug 7, 2019 at 3:17 AM hui zhang wrote: > //export Send > func Send(confid string, len int, pcm *C.short) { >//put c.short array to int16 slice/array efficiently , how ? >// memcopy ? > } s := (*[^uint(0) >> 1]int16)(unsafe.Pointer(pcm))[:len] // s is []int16, len(s) = len --

Re: [go-nuts] Hexadecimal floats

2019-07-26 Thread Jan Mercl
There are several NaNs, but only a single bit pattern for IEEE754 infinity (modulo the sign bit). So yes, your suggestion should work well. Thank you, I'll give it a try. On Sat, Jul 27, 2019, 07:44 Adrian Ho wrote: > On 26/7/19 9:20 PM, Jan Mercl wrote: > > In a program that generat

Re: [go-nuts] Hexadecimal floats

2019-07-27 Thread Jan Mercl
On Sat, Jul 27, 2019 at 7:44 AM Adrian Ho wrote: It works: https://gitlab.com/cznic/qbe/commit/0cdebdce50edb146df981b6b484bad57eddb9e94#97b5d71a8f6b71eb5bf032969fb4a29f9d89eef4_1175_1177 Thanks again. -- You received this message because you are subscribed to the Google Groups "golang-nuts"

Re: [go-nuts] Go Library lists

2019-08-06 Thread Jan Mercl
On Tue, Aug 6, 2019 at 3:51 PM wrote: > If anyone knows of a currently maintained equivalent , please respond Check https://github.com/golang/go/wiki/Projects -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and

Re: [go-nuts] Re: Question re fcns that return multiple values

2019-08-06 Thread Jan Mercl
On Tue, Aug 6, 2019 at 4:07 PM wrote: > > Here a specific example: > > The following compiles and runs as expected > m1x,m1y := ec.scalarMult(16,28,33) > m2x,m2y := ec.scalarMult( 1,28,33) > rx,ry := ec.add (m1x,m1y, m2x, m2y) > > > However this stmt :rx,ry= ec.add(ec.scalarMult(16,28,33),

Re: [go-nuts] how to pass c array to golang efficiently

2019-08-06 Thread Jan Mercl
On Tue, Aug 6, 2019 at 11:11 AM hui zhang wrote: Please always send code to the ML as plain, black on white text. And/or use play.golang.org. Thanks. -- 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] sqlite x ql

2019-07-17 Thread Jan Mercl
On Wed, Jul 17, 2019 at 4:34 PM Luis Furquim wrote: > Has anyone any information about performance comparison between Sqlite and Ql > (github.com/cznic/ql or modernc.org/ql)? Any bit of information would be > appreciated! QL is slower. Sometimes dramatically slower. QL's query

Re: [go-nuts] Get struct type , save and reconstruct empty struct later

2019-07-20 Thread Jan Mercl
On Sat, Jul 20, 2019 at 9:28 AM Vasiliy Tolstov wrote: > Hi. I have reflection based question. > I need to store type of struct passed to func and later based on this stored > type reconstruct empty needed struct. > Does this possible ? Not sure I understood the question:

Re: [go-nuts] Re: About the Google logo on the new Go website

2019-07-20 Thread Jan Mercl
On Fri, Jul 19, 2019 at 10:39 PM Cassandra Salisbury wrote: > > I encourage everyone to take a look at the code of conduct. I have had > multiple reports from this particular thread. I, for one, have no idea why. But I guess Kafka would be delighted by this mysteriosity. -- You received this

Re: [go-nuts] Re: About the Google logo on the new Go website

2019-07-17 Thread Jan Mercl
On Wed, Jul 17, 2019 at 8:07 AM Michael Jones wrote: > > I'm a reader here, so @all includes me. In regards to Oracle, I was delighted > when they released VirtualBox under GPL and remain delighted that they pay > Oracle employees to enhance it and share their work. I'm a thankful user of

Re: [go-nuts] "Go to" one line before the declaration

2019-07-17 Thread Jan Mercl
On Wed, Jul 17, 2019 at 11:24 AM wrote: > > Can somebody explain this code? > How is the cpu doing? better than for{} ... Who claims it's doing better than `for {}`? IDK, I haven't tested, but I guess it should perform the same bad way. > ... and select {} in CPU usage? Now that's a different

[go-nuts] Hexadecimal floats

2019-07-26 Thread Jan Mercl
In a program that generates C, I'm using big.Float.Text (https://golang.org/pkg/math/big/#Float.Text) to produce the exact value of the C floating point literal. As it turns out, the function does not support Inf values. Instead of encoding the exact bits of the Inf value, the resulting string is

Re: [go-nuts] Need explaination for code

2019-07-26 Thread Jan Mercl
On Fri, Jul 26, 2019 at 8:15 PM thatipelli santhosh wrote: > Can anyone please explain this piece of code? this would be more helpful to > me to understand this. Thank you! I don't know what "explain this code" means in this case. But maybe this can help: https://play.golang.org/p/t4yDlOwG-rv

Re: [go-nuts] Clarification on unsafe conversion between string <-> []byte

2019-09-23 Thread Jan Mercl
On Mon, Sep 23, 2019 at 11:37 AM wrote: > ... and the problems with storing a uinptr in a variable are mostly related > to moving garbage collectors ... Please note that even though, AFAIK, none of the Go compilers so far uses a moving GC, it's not the only source of objects being moved

Re: [go-nuts] Migrating Google App Engine Go app to Go 1.12

2019-09-30 Thread Jan Mercl
On Mon, Sep 30, 2019 at 12:34 PM Matthew Zimmerman wrote: > > My notice said that apps continue to run, you just can't deploy new versions. > > "Starting on October 1, 2019, as per our deprecation policy, you will no > longer be able to deploy new versions of App Engine Standard applications >

[go-nuts] Re: Migrating Google App Engine Go app to Go 1.12

2019-09-30 Thread Jan Mercl
On Mon, Sep 30, 2019 at 11:32 AM Jan Mercl <0xj...@gmail.com> wrote: Panic mode off. Deployed, seems to work: https://gitlab.com/cznic/modernc/commit/96339947ba67960ae5bd19b625b2816fdcc7af6e Thanks to anyone who have read the OP. -- You received this message because you are subs

[go-nuts] Migrating Google App Engine Go app to Go 1.12

2019-09-30 Thread Jan Mercl
Hi list. The modernc.org domain go-get redirector is hosted at the Google App Engine and provides access to all packages found at this time at https://gitlab.com/cznic. Go code for the redirector iself is published at https://gitlab.com/cznic/modernc. The instance dashboard shows a warning: "A

Re: [go-nuts] The "leave "if err != nil" alone?" anti-proposal

2019-06-30 Thread Jan Mercl
On Sun, Jun 30, 2019 at 3:19 PM Jesper Louis Andersen wrote: > This is where the try-construct will definitely improve the ergonomics of the > programming. With full respect to you opinion and/or personal preferences, "definitely improve" is just and only that. I _definitely_ don't share that

Re: [go-nuts] Newbie question on slice bound checking

2019-06-16 Thread Jan Mercl
On Sun, Jun 16, 2019, 13:53 Ugorji Nwoke wrote: > I know this is an old thread, but is -B still supported? > That compiler flag provides compiling a program, semantic of which isn't compatible with the Go language specification. It's only valid use is to enable easy evaluation of the bounds

[go-nuts] [ANN] QBE compiler (proof of concept)

2019-11-04 Thread Jan Mercl
See: https://godoc.org/modernc.org/qbe/qbec There's also qbefmt: https://godoc.org/modernc.org/qbe/qbefmt -- 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

Re: [go-nuts] strict type assignability to prevent arbitrary values

2019-11-07 Thread Jan Mercl
On Thu, Nov 7, 2019 at 11:58 AM bsr wrote: > Is there a way I can prevent this behavior. Yes, if the rules for untyped literals are not wanted, make the literal typed: https://play.golang.org/p/-f75y0Gb1Is -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] Задача: Дано число int 324. Как получить 9?

2019-12-04 Thread Jan Mercl
On Wed, Dec 4, 2019 at 2:49 PM Vital Nabokov wrote: > > Добрый день. > Задача: №1 Дано число int 324. Как получить int 9? > Задача: №2 Дано число string "324". Как получить int 9? This mailing list is in English: https://groups.google.com/forum/#!aboutgroup/golang-nuts Please use the mailing

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"

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

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

Re: [go-nuts] Extending an array 'The right way'. Guidence needed!

2019-10-15 Thread Jan Mercl
On Tue, Oct 15, 2019 at 12:16 PM Stuart Davies wrote: > I have a slice backed by an array. > > My understanding is that I can extend the slice (append) up to the capacity > of the array. I guess that by 'extend the slice' you mean reslicing. Yes, that can be done while len <= cap. However,

Re: [go-nuts] Need help with godbus.

2019-11-20 Thread Jan Mercl
On Tue, Nov 19, 2019 at 5:21 PM Ken Bassford wrote: Please always post source code to the mail list in plain black on white only, thank you. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving

Re: [go-nuts] About Libraries Versioning

2019-11-20 Thread Jan Mercl
On Wed, Nov 20, 2019 at 2:42 PM Eyal wrote: > The recommended way to create a new version for a go library is by copying > the library code to a v2 directory. Only if the new version that breaks backward compatibility. Bug fixes and/or new features do not need such switch. -- You received

Re: [go-nuts] [ANN] Golang Oriented to Aspects (goa) v0.0.1 is released!!!

2019-11-26 Thread Jan Mercl
On Mon, Nov 25, 2019 at 10:47 PM Iván Corrales Solera wrote: > Source ode https://github.com/wesovilabs/goa > Full documentation http://wesovilabs.github.io/goa Would you mind changing the name of the language to the proper form everywhere in the above quoted links? Some people may chose to

Re: [go-nuts] Change slice type

2019-11-27 Thread Jan Mercl
On Thu, Nov 28, 2019 at 3:16 AM Michael Jones wrote: > > The general rule -- if there can be a general rule for risk behavior -- is > that CPUs like having addresses aligned on an integer multiple of the data > element size. So: > > access-as-byte data may be on any address (address&(1-1)==0),

Re: [go-nuts] Re: [golang-dev] go.dev is live!

2019-11-14 Thread Jan Mercl
On Thu, Nov 14, 2019 at 5:55 AM Dan Kortschak wrote: > It looks like license detection needs work. > > See https://pkg.go.dev/gonum.org/v1/gonum?tab=overview and note it has > a BSD 3 clause, as shown by GitHub's assessment (just above the "Clone > or download" button) at

Re: [go-nuts] nil map assignment panics. can we do better?

2019-09-24 Thread Jan Mercl
On Tue, Sep 24, 2019 at 10:11 PM Marcin Romaszewicz wrote: > > Could we have an operation like append() for slices? > > How about: > > m := insert(m, "key", "value"). A slice is a value but a map is implemented as a pointer. IOW, the line of code quoted above updates only the locally visible

Re: [go-nuts] rebuild & reinstall pkg/tool/.../link

2019-10-09 Thread Jan Mercl
On Wed, Oct 9, 2019 at 12:10 PM Liam wrote: > > I have the current 1.12 release from a Linux distro, installed in /usr/lib/go. > > If I patch the linker source, how would I rebuild and reinstall > pkg/tool/.../link ? I think there are two options: - Learn how to make the distro's package from

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] 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] [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: 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

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

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

[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

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. >

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] 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

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

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.

[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: 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

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

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

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,

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

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

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

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,

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

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 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] 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

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 >

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

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 _name (type *[25]_Ctype_char) as type *_Ctype_char in > argument to _Cfunc_GoString Oh yeah, should have been probably `C.GoString([0])`. Forgot Go

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

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

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

[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

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

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 >

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

2020-05-14 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

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] 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

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

2020-05-09 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

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

Re: [go-nuts] go install puts my library .a file in the local directory instead of first component of GOPATH

2020-09-06 Thread Jan Mercl
On Sun, Sep 6, 2020 at 9:15 PM Dean Schulze wrote: > When I execute go install datepackage I get This is may or may not be the cause, but please note that import paths without a dot, like the one quoted above, are reserved (https://github.com/golang/go/issues/32819#issuecomment-566671328) for

Re: [go-nuts] linux/arm struct alignment seems wrong

2020-09-09 Thread Jan Mercl
On Wed, Sep 9, 2020 at 1:45 PM 'Dan Kortschak' via golang-nuts wrote: > I think it comes down to these lines in src/cmd/internal/sys/arch.go > [1] > > ``` > var ArchARM = { > Name: "arm", > Family:ARM, > ByteOrder: binary.LittleEndian, > PtrSize: 4, >

Re: [go-nuts] linux/arm struct alignment seems wrong

2020-09-09 Thread Jan Mercl
On Wed, Sep 9, 2020 at 1:09 PM 'Dan Kortschak' via golang-nuts < golang-nuts@googlegroups.com> wrote: > What does cgo -godefs give you? On my amd64 and arm64 I get this: > > ``` > ~/cznic $ cat main.go > package main > > /* > struct s { > long long i; > } x; > */ > import "C" > > type S

[go-nuts] linux/arm struct alignment seems wrong

2020-09-09 Thread Jan Mercl
Observation: pi@raspberrypi:~/src/tmp.tmp $ go version go version go1.15.1 linux/arm pi@raspberrypi:~/src/tmp.tmp $ cat main.go package main /* struct s { long long i; } x; size_t align() { return _Alignof(struct s); } */ import "C" import ( "fmt" "unsafe" )

Re: [go-nuts] linux/arm struct alignment seems wrong

2020-09-09 Thread Jan Mercl
On Wed, Sep 9, 2020 at 12:41 PM Dan Kortschak wrote: > I get the following > > ``` > C alignof struct s: 8 > Go alignof struct s: 8 > Go alignofS: 8 > ~/cznic $ go version > go version go1.15.1 linux/arm64 > ~/cznic $ uname -a > Linux bildr 4.19.0-10-arm64 #1 SMP Debian 4.19.132-1

Re: [go-nuts] linux/arm struct alignment seems wrong

2020-09-09 Thread Jan Mercl
On Wed, Sep 9, 2020 at 8:17 PM Ian Lance Taylor wrote: > Exact alignment/offset compatibility with the C ABI is not a goal. > Sorry. (It's actually harder than one might think to maintain that > kind of compatibility. For example, on x86, the C ABI uses one > alignment for double variables and

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