Re: [go-nuts] where is GOROOT set?

2022-11-24 Thread Brian Candler
Your error comes from the spurious import of "treesort" in treesort_test.go. (You are already inside package treesort; there is nothing to import) With this line: $ go test . # example.com/blah treesort_test.go:11:2: package treesort is not in GOROOT (/usr/local/go/src/treesort) FAIL

Re: [go-nuts] How to cast *interface{} into *T ?

2022-11-24 Thread Nigel Tao
Possibly relevant: https://go.dev/doc/faq#pointer_to_interface -- 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 view

Re: [go-nuts] How to cast *interface{} into *T ?

2022-11-24 Thread 'Axel Wagner' via golang-nuts
To be clear what I mean with "not particularly functional": Your GetOf is just doing a type-assertion, so the right way to write it would be this: https://go.dev/play/p/hTqOCbc07-K You must have a reason to go through the more complicated dance of your GetOf function, but without knowing that,

Re: [go-nuts] How to cast *interface{} into *T ?

2022-11-24 Thread 'Axel Wagner' via golang-nuts
On Fri, Nov 25, 2022 at 12:14 AM Denis P wrote: > Ok, looks like it doesn't work. > > I have got the following error: > panic: interface conversion: interface {} is MyStruct, not *MyStruct > > So the actual code is this: https://go.dev/play/p/jBiPII7rOxG > > Cannot find out what is going on :-(

Re: [go-nuts] Does Go optimize math.Float64frombits(binary.LittleEndian.Uint64[...])) to a single instruction?

2022-11-24 Thread Ian Lance Taylor
On Thu, Nov 24, 2022 at 3:16 PM twp...@gmail.com wrote: > > tl;dr: on 64-bit little-endian machines, does > > x := math.Float64frombits(binary.LittleEndian.Uint64(byteSlice[:8])) > > get optimized to a single move instruction from byteSlice[:8] to x? > > > Background info: > > I'm currently

Re: [go-nuts] How to cast *interface{} into *T ?

2022-11-24 Thread Denis P
Ok, finally got it: https://go.dev/play/p/QFQOpqWsR6S Thanks everyone, especially Axel On Thursday, 24 November 2022 at 23:14:27 UTC Denis P wrote: > Ok, looks like it doesn't work. > > I have got the following error: > panic: interface conversion: interface {} is MyStruct, not *MyStruct > > So

[go-nuts] Does Go optimize math.Float64frombits(binary.LittleEndian.Uint64[...])) to a single instruction?

2022-11-24 Thread twp...@gmail.com
tl;dr: on 64-bit little-endian machines, does x := math.Float64frombits(binary.LittleEndian.Uint64(byteSlice[:8])) get optimized to a single move instruction from byteSlice[:8] to x? Background info: I'm currently writing a bunch of code that unmarshals binary data. A small example is

Re: [go-nuts] How to cast *interface{} into *T ?

2022-11-24 Thread Denis P
Ok, looks like it doesn't work. I have got the following error: panic: interface conversion: interface {} is MyStruct, not *MyStruct So the actual code is this: https://go.dev/play/p/jBiPII7rOxG Cannot find out what is going on :-( On Thursday, 24 November 2022 at 22:29:21 UTC

Re: [go-nuts] clarifying Go FAQ: Is Go an object-oriented language?

2022-11-24 Thread Sven Anderson
Ayan George schrieb am Di. 22. Nov. 2022 um 16:03: > > The Go FAQ begins the answer to the question, "Is Go an object-oriented > language," with, "yes and no." > […] > But I feel like programmers bringing their ideas from other less > ambiguously object oriented languages like Java and C++

[go-nuts] How to cast *interface{} into *T ?

2022-11-24 Thread Denis P
Hi guys, tried to look everywhere and cannot find an answer. So literally I have this: ``` var result interface{} = {} ... return result.(*MyStruct) // Error: invalid operation: result (variable of type *interface{}) is not an interface ``` Is there any way to get the as a result? -- You

Re: [go-nuts] clarifying Go FAQ: Is Go an object-oriented language?

2022-11-24 Thread robert engels
OO as a fad? This is Thanksgiving not April Fool’s Day. > On Nov 24, 2022, at 3:25 PM, TheDiveO wrote: > > Reading the "yes and no" part as a newcomer to Go actually made me snigger > and I though that this kind of answer shows a thorough and differentiated > thinking not shy of dealing with

[go-nuts] Re: Problems with array slicing reliability?

2022-11-24 Thread TheDiveO
On Wednesday, November 23, 2022 at 10:57:03 PM UTC+1 loji...@gmail.com wrote: > [...] I am using an AMG64 computer with Windows 10, and *Go version > 0.36.0.* [*emphasis mine*] > Go version 0.36.0? Really? -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] Re: clarifying Go FAQ: Is Go an object-oriented language?

2022-11-24 Thread TheDiveO
Reading the "yes and no" part as a newcomer to Go actually made me snigger and I though that this kind of answer shows a thorough and differentiated thinking not shy of dealing with complexity as it is without trying to flee into simple and useless label simplification. IMHO the problem is not

Re: [go-nuts] Method chaining in multiple lines

2022-11-24 Thread Harris, Andrew
Period should be at the end of lines Call(). Chain(). Done() Get Outlook for iOS From: golang-nuts@googlegroups.com on behalf of Denis P Sent: Thursday, November 24, 2022 11:45:54 AM To: golang-nuts Subject: [go-nuts] Method chaining

[go-nuts] Method chaining in multiple lines

2022-11-24 Thread Denis P
Hi guys, I am struggling with making my code work in a way that multiple methods called in multiline approach. Does any gopher has an answer is there any solution to this: ``` type MyStuff struct { } func CreateMyStuff() MyStuff {} func (s MyStuff) DoJobOne() MyStuff {} func (s MyStuff)

Re: [go-nuts] Re: clarifying Go FAQ: Is Go an object-oriented language?

2022-11-24 Thread Kamil Ziemian
"Saying "yes or no" is a non-answer. :)" >From people new to coding, I guess so. For people with good background, this is a good answer, since rest of the FAQ entry explain enough that they can say "Ok. I think I'm getting it.". BTW in FAQ it is "Yes and no.". So true question is: who is asking

Re: [go-nuts] Re: clarifying Go FAQ: Is Go an object-oriented language?

2022-11-24 Thread Kamil Ziemian
I will start with cautionary tell. At one of his public talks Bjarne Stroustrup in some way, admited that he made a very bad job when teaching people C++ and now we must live with many bad practices being a norm and even adviced as good practices. In Stroustrup words "I didn't care about "Let

Re: [go-nuts] Re: clarifying Go FAQ: Is Go an object-oriented language?

2022-11-24 Thread Kamil Ziemian
" Let me ask, because I'm genuinely curious: Why does it matter? The labels we apply to things do not affect their function. Perhaps it affects how we think about them. Is that it?" My point of view is that. In the moment when you learn the flow of language X, it doesn't matter. But, it is not

[go-nuts] Re: Please help me with structure data alignment

2022-11-24 Thread Maxim Velivanov
My bad. it turns out that the API dll has a directive #pragma pack (1) On Thursday, November 24, 2022 at 7:08:54 AM UTC+2 Maxim Velivanov wrote: > Hi, > > I'm developing a Go wrapper for a dll. > dll contains the following structure: > struct ck_version { > unsigned char major; > unsigned

[go-nuts] Re: Go 1.20 release date

2022-11-24 Thread Piotr Wyderski
Thank you Ben and Amnon! wtorek, 22 listopada 2022 o 22:50:02 UTC+1 ben...@gmail.com napisał(a): > You can also use the "gotip" command ( > https://pkg.go.dev/golang.org/dl/gotip) to pull the latest, unreleased > version from the Go development tree. > > -Ben > > On Wednesday, November 23, 2022

[go-nuts] Re: How to High-pass filter method for well height data

2022-11-24 Thread Brian Candler
On Wednesday, 23 November 2022 at 19:02:29 UTC seokta...@gmail.com wrote: > I looked for dsp filter through the gitbub, but the bandpass filter was > focused always. > > I don't know this for sure, and you should check with your supervisor if necessary. But I suspect your supervisor was *not*

Re: [go-nuts] where is GOROOT set?

2022-11-24 Thread Brian Candler
On Wednesday, 23 November 2022 at 23:25:51 UTC pat2...@gmail.com wrote: > I've separated my code into separate subdirectories, added a go.mod > ran go mod tidy on each. > > I'm mostly back where I started, which a better source file tree > > I'm trying to test the "treesort" package from the