[go-nuts] Re: Using Go in picore (tinycore)

2023-12-06 Thread awaw
Good point, perhaps cross compiling with GOOS=linux and GOARCH=arm would be 
the easiest path.
Can anyone share their experiences with regard to actually doing this on 
tinycore, and it indeed works?

On Wednesday 6 December 2023 at 16:21:34 UTC+8 Brian Candler wrote:

> You should note that you don't necessarily need to install the go compiler 
> on your target machine. You can build ARM binaries on an x86_64 machine for 
> example - set the parameters GOOS and GOARCH. Go is especially good for 
> this sort of cross-compilation, as it doesn't require any special 
> toolchains to be installed. It's out-of-the-box functionality.
>
> But if you do want to run go on the target system itself, then I'd expect 
> just installing the binary distribution should work.  Try it and see!
>
> As for crash safety: it's normally a matter of what type of filesystem is 
> being used.
>
> On Wednesday 6 December 2023 at 02:04:35 UTC 王富民awaw wrote:
>
>> Hi Gophers and embedded systems experts
>>
>> How can I use the latest version of Go, 1.21.5, in picore 
>> <http://tinycorelinux.net/5.x/armv6/releases/README>, which is the 
>> raspberry pi port of the lightweight linux OS tinycore 
>> <http://tinycorelinux.net/>?
>> Although, the x86_64 version includes 
>> <http://tinycorelinux.net/14.x/x86_64/tcz/>Go, the picore version doesn't 
>> <http://tinycorelinux.net/14.x/armv6/tcz/>.
>>
>> To use Go, could I simply download
>>
>> https://go.dev/dl/go1.21.5.linux-armv6l.tar.gz
>>
>> into the picore OS, and simply use Go straightaway?
>> If not, can anyone share the steps to compile Go from source on picore?
>>
>> If anyone is curious why we're not using the default raspberry pi OS,
>> it is because our users often unplug the pi's power abruptly without 
>> proper shutdown causing sd card corruption and eventually OS boot failures. 
>> To this end, we also evaluated TinyGo, but there are two issues:
>> * TinyGo does not have wifi 
>> <https://github.com/tinygo-org/tinygo/issues/2947>yet.
>> * We need to segment 
>> <https://ffmpeg.org/ffmpeg-formats.html#segment_002c-stream_005fsegment_002c-ssegment>live
>>  
>> stream from a camera, and thus need ffmpeg
>>
>> Some people in the raspberry pi community recommend Ultibo 
>> <https://ultibo.org/>for use cases where abrupt power unplugging is 
>> required.
>> However, since Ultibo is not Go, I'd preferably rather not use it, as I 
>> really don't want to code in anything other than Go.
>>
>

-- 
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 this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e3143e0e-f71b-40b2-8ec7-48c4880f6bcdn%40googlegroups.com.


[go-nuts] Using Go in picore (tinycore)

2023-12-05 Thread awaw
Hi Gophers and embedded systems experts

How can I use the latest version of Go, 1.21.5, in picore 
, which is the 
raspberry pi port of the lightweight linux OS tinycore 
?
Although, the x86_64 version includes 
Go, the picore version doesn't 
.

To use Go, could I simply download

https://go.dev/dl/go1.21.5.linux-armv6l.tar.gz

into the picore OS, and simply use Go straightaway?
If not, can anyone share the steps to compile Go from source on picore?

If anyone is curious why we're not using the default raspberry pi OS,
it is because our users often unplug the pi's power abruptly without proper 
shutdown causing sd card corruption and eventually OS boot failures. 
To this end, we also evaluated TinyGo, but there are two issues:
* TinyGo does not have wifi 
yet.
* We need to segment 
live
 
stream from a camera, and thus need ffmpeg

Some people in the raspberry pi community recommend Ultibo 
for use cases where abrupt power unplugging is 
required.
However, since Ultibo is not Go, I'd preferably rather not use it, as I 
really don't want to code in anything other than Go.

-- 
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 this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/6d56ad37-e171-4997-bb87-79ec3a42806fn%40googlegroups.com.


[go-nuts] Multiple multicast listeners in different goroutines

2023-11-14 Thread awaw
Hi Gophers and network experts,

I am calling `net.ListenMulticastUDP` in each http handler, attempting to 
act as a fan-out proxy to multiple browsers, since browsers cannot connect 
to UDP directly.

However, at any given time, only one single UDP listener is able to read 
data from the socket.
Only when the first browser disconnects, can the second browser start 
receiving subsequent data.

I wonder is this a limitation on `net.ListenMulticastUDP`, or is this a 
limitation of the UDP protocol itself?

-- 
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 this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/fb308df9-256f-446b-a422-049cbb64230dn%40googlegroups.com.


Re: [go-nuts] Re: recommended statistics package? Requirements: ANOVA, Brown-Forsythe

2023-10-30 Thread awaw
Hi Jason

Thanks for your suggestion.
I have renamed the function Levene to BrownForsythe, as well as added a 
comment to note that it assumes its input to be sorted ascendingly.

On Tuesday, 31 October 2023 at 02:18:51 UTC+8 Jason E. Aten wrote:

>
> On Monday, October 30, 2023 at 3:14:29 AM UTC 王富民awaw wrote:
>
> Therefore, perhaps I should not be following scipy and rename my function 
> from Levene to BrownForsythe?
>
>  
> Since you have made it available to the public Go community, yes, it would 
> be a good idea to name it BrownForsythe,
> as it is using the deviations from the group medians.
>
> Also the function makes the assumption, as does Median, that each group's 
> samples[j] is already sorted. You
> should document that assumption, or sort.Slice() each group's sample 
> before calling Median.
>

-- 
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 this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e12012dc-36c5-43e2-a165-02b0a480cce0n%40googlegroups.com.


Re: [go-nuts] Re: recommended statistics package? Requirements: ANOVA, Brown-Forsythe

2023-10-29 Thread awaw
Hi Jason

Yes, I concur that the function "Levene" named in my package should really 
be called Brown-Forsthe.

I was vacillating between this correct naming versus following the 
nomenclature of scipy 
<https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.levene.html>from
 
which my implementation is numerically tested against.

I looked at a couple of popular statistics software, and it seems that most 
differentiate between Levene and Brown-Forsythe

* JMP 
<https://www.jmp.com/support/help/en/17.2/#page/jmp/unequal-variances-reports.shtml>
* SPSS 
<https://www.ibm.com/docs/en/spss-statistics/28.0.0?topic=anova-one-way-options>
* R <https://search.r-project.org/CRAN/refmans/ALSM/html/3_bftest.html>

Therefore, perhaps I should not be following scipy and rename my function 
from Levene to BrownForsythe?
I admit I am no statistician and would appreciate some professional 
guidance.
On Monday, 30 October 2023 at 10:41:23 UTC+8 Jason E. Aten wrote:

> 王富民awaw: Very nice.
>
> The Levene function, though, is confusingly named. The Levene test is 
> distinct from the Brown-Forsthe test, so mixing up the names
> seems odd.[1]
>
> [1] quoting 
> https://www.statisticshowto.com/brown-forsythe-test/#:~:text=The%20Levene%20test%20uses%20deviations,a%20test%20that's%20more%20robust.
>   
> below: (see the underlined sentence, underline and bold there is mine)
>
> How the Test Works
>
> Both the Levene and B-F tests transform dependent variables 
> <https://www.statisticshowto.com/dependent-variable-definition/> for use 
> in an ANOVA  
> <https://www.statisticshowto.com/probability-and-statistics/hypothesis-testing/anova/>test.
>  
> The only difference between the two tests is in how those transformed 
> variables are constructed. The Levene test uses deviations from group 
> means <https://www.statisticshowto.com/mean/>, which usually results in a 
> highly-skewed set of data; This violates the assumption of normality 
> <https://www.statisticshowto.com/assumption-of-normality-test/>.* The 
> Brown-Forsythe test attempts to correct for this skewness  
> <https://www.statisticshowto.com/probability-and-statistics/descriptive-statistics/skewness/>by
>  
> using deviations from group medians 
> <https://www.statisticshowto.com/probability-and-statistics/statistics-definitions/mean-median-mode/#median>.*
>  
> The result is a test that’s more robust 
> <https://www.statisticshowto.com/robust-statistics/>. In other words, the 
> B-F test is less likely than the Levene test to incorrectly declare that 
> the assumption of equal variances has been violated.
>
> The test works as follows:
>
>- The median is calculated for each factor level group.
>- The median value is subtracted from each dependent variable in the 
>group.
>- An ANOVA 
>
> <https://www.statisticshowto.com/probability-and-statistics/hypothesis-testing/anova/>
>  is 
>run with the transformed variables. If a factor’s p-value 
>
> <https://www.statisticshowto.com/probability-and-statistics/statistics-definitions/p-value/>
>  is 
>less than the significance level 
>
> <https://www.statisticshowto.com/probability-and-statistics/statistics-definitions/what-is-an-alpha-level/>
>  (usually 
>5%), the population variances are not equal.
>
> W or F statistic?
>
> The test statistic used in a regular ANOVA is an F-statistic 
> <https://www.statisticshowto.com/probability-and-statistics/f-statistic-value-test/>.
>  
> The statistic used in an ANOVA with transformed variables is sometimes 
> called a W-Statistic — but it’s really just an F-Statistic with a 
> different name. It should not be confused with the coefficient of 
> concordance W-statistic 
> <https://www.statisticshowto.com/concordance-correlation-coefficient/>, 
> which is used to assess agreement between raters.
> Cautions
>
> For the most part, the B-F test is thought to perform as well as or better 
> than other available tests for equal variances. However, Glass and Hopkins 
> (1996 p. 436) state that the Levene and B-F tests are “fatally flawed”; It 
> isn’t clear how robust they are when there is significant differences in 
> variances and unequal sample sizes. Hill et. al (2006) advise repeating the 
> test using a non-parametric 
> <https://www.statisticshowto.com/probability-and-statistics/statistics-definitions/parametric-and-non-parametric-data/>
>  method.
>
> On Monday, October 30, 2023 at 1:08:19 AM UTC 王富民awaw wrote:
>
>> Hi Jan,  Martin, and Jason
>>
>> Thanks for your tips and encouragement for rolling our sleeves.
>> I have put together a small statistics library:
>>

Re: [go-nuts] Re: recommended statistics package? Requirements: ANOVA, Brown-Forsythe

2023-10-29 Thread awaw
Hi Jan,  Martin, and Jason

Thanks for your tips and encouragement for rolling our sleeves.
I have put together a small statistics library:

stat package - github.com/fumin/stat - Go Packages 
<https://pkg.go.dev/github.com/fumin/stat>

For my own needs, in addition to Brown-Forsythe, I also needed the Welch 
t-test and tools for multiple testing, so these are what's in the above 
package.

On Monday, 30 October 2023 at 07:25:50 UTC+8 Jason E. Aten wrote:

> For the ANOVA, I usually just call from Go into R for such things -- at 
> least until I 
> can validate if its the right thing to do/ meets the sensitivity/power 
> needs of the analysis.
>
> https://statsandr.com/blog/anova-in-r/
>
>
> https://github.com/glycerine/rmq#and-the-reverse-embedding-r-inside-your-golang-program
>
>
> On Wednesday, October 25, 2023 at 6:48:56 AM UTC+1 Jan wrote:
>
>> So cool!
>> On Monday, October 23, 2023 at 5:44:29 PM UTC+2 Martin Schnabel wrote:
>>
>>> Hi, 
>>>
>>> I attempted to translate the linked JS implementation for fun. Maybe 
>>> someone can use it as a starting point and correct or verify its 
>>> correctness. 
>>>
>>> https://go.dev/play/p/Wrw2yDRof0z 
>>>
>>> Have fun! 
>>>
>>> On 10/23/23 07:38, Jan wrote: 
>>> > hi, I did a quick search and I didn't find anything in Go. But looking 
>>> > at the definition and at one implementation in JS 
>>> > <
>>> https://github.com/lukem512/brown-forsythe-test/blob/master/src/brown-forsythe.js>,
>>>  
>>> it sounds something relatively easy to write and share :)  You can use the 
>>> R implementation to create some test datasets. Maybe gonum/stat <
>>> https://godocs.io/gonum.org/v1/gonum/stat> would be a potential home 
>>> for such a function ? What do you think ? 
>>> > 
>>> > cheers 
>>> > On Friday, October 20, 2023 at 10:54:55 AM UTC+2 王富民awaw wrote: 
>>> > 
>>> > Hi follow Gophers 
>>> > 
>>> > I wonder is there a canonical, verifiably correct Go package for 
>>> > statistics? 
>>> > In particular, Go code that does the Brown-Forsythe test of equal 
>>> > variance. 
>>> > Ideally in pure Go, but linking with CGo is OK. 
>>> > 
>>> > A search on Google and pkg.go.dev <http://pkg.go.dev> does not 
>>> > return helpful results. 
>>> > I wonder is there anything that the community could share? 
>>> > 
>>> > -- 
>>> > 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...@googlegroups.com 
>>> > <mailto:golang-nuts...@googlegroups.com>. 
>>> > To view this discussion on the web visit 
>>> > 
>>> https://groups.google.com/d/msgid/golang-nuts/7ee10c0f-8af6-4b31-baaf-ce2ccb9c0211n%40googlegroups.com
>>>  
>>> <
>>> https://groups.google.com/d/msgid/golang-nuts/7ee10c0f-8af6-4b31-baaf-ce2ccb9c0211n%40googlegroups.com?utm_medium=email_source=footer>.
>>>  
>>>
>>>
>>

-- 
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 this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/f0437c9c-5ed5-42ec-ba4d-5dc3ee43ad40n%40googlegroups.com.


[go-nuts] recommended statistics package? Requirements: ANOVA, Brown-Forsythe

2023-10-20 Thread awaw
Hi follow Gophers

I wonder is there a canonical, verifiably correct Go package for statistics?
In particular, Go code that does the Brown-Forsythe test of equal variance.
Ideally in pure Go, but linking with CGo is OK.

A search on Google and pkg.go.dev does not return helpful results.
I wonder is there anything that the community could share?

-- 
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 this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/6431764c-b732-4dd4-8d0a-e69b43f51298n%40googlegroups.com.


[go-nuts] Re: Is there a race in exec.CombinedOutput?

2023-10-04 Thread awaw
That's interesting!
Thanks Jason and Brian for educating me! Thanks!

On Wednesday, 4 October 2023 at 20:36:10 UTC+8 Brian Candler wrote:

> Code reference:
>
> https://cs.opensource.google/go/go/+/refs/tags/go1.21.1:src/os/exec/exec.go;l=523-565
>
> * c.writerDescriptor creates the pipe, and a copying function is appended 
> to the slice c.goroutine. This slice contains the functions which will be 
> started in their own goroutines.
> * c.childStdout calls c.writerDescriptor
> * c.childStderr reuses the exiting childStdout if Stdout and Stderr are 
> the same (and therefore there is still only one function in c.goroutine)
> * interfaceEqual implements the check that Jason quoted:
>
> https://cs.opensource.google/go/go/+/refs/tags/go1.21.1:src/os/exec/exec.go;l=473-480
>
> On Wednesday, 4 October 2023 at 05:58:29 UTC+1 Jason Phillips wrote:
>
>> From the Stdout/Stderr field documentation on the os/exec.Cmd type 
>> <https://pkg.go.dev/os/exec#Cmd>:
>>
>> "If Stdout and Stderr are the same writer, and have a type that can be 
>> compared with ==, at most one goroutine at a time will call Write."
>>
>> On Tuesday, October 3, 2023 at 9:55:16 PM UTC-4 王富民awaw wrote:
>>
>> exec.CombinedOutput uses the same io.Writer for both stdout and stderr 
>> in  exec.go - Go (opensource.google) 
>> <https://cs.opensource.google/go/go/+/refs/tags/go1.21.1:src/os/exec/exec.go;l=1003>
>>  .
>> This io.Writer is written in  exec.go - Go (opensource.google) 
>> <https://cs.opensource.google/go/go/+/refs/tags/go1.21.1:src/os/exec/exec.go;l=717>
>>  .
>> These two writes happens concurrently in two goroutines in exec.go - Go 
>> (opensource.google) 
>> <https://cs.opensource.google/go/go/+/refs/tags/go1.21.1:src/os/exec/exec.go;l=717>
>>  .
>> As far as I know, bytes.Buffer is not safe to concurrent writes.
>> Is this not a race?
>>
>>

-- 
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 this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/faa824a0-85a5-4e02-9ed3-9a451c2f0b1en%40googlegroups.com.


[go-nuts] Is there a race in exec.CombinedOutput?

2023-10-03 Thread awaw
exec.CombinedOutput uses the same io.Writer for both stdout and stderr in  
exec.go 
- Go (opensource.google) 

 .
This io.Writer is written in  exec.go - Go (opensource.google) 

 .
These two writes happens concurrently in two goroutines in exec.go - Go 
(opensource.google) 

 .
As far as I know, bytes.Buffer is not safe to concurrent writes.
Is this not a race?

-- 
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 this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/c8287fa4-8e9b-46bb-a2aa-7abd56157cdcn%40googlegroups.com.


[go-nuts] Loop label style question

2023-10-02 Thread awaw
I wonder does anyone know the reason and history of why loop labels are 
styled as such:

* Labels are *unindented*.
  All Go constructs, such as fields in structs indent to the right.
  Why does loop labels unindented to the left?
* Labels start with capital letters.
  Since all other Go identifiers start with lower case, why is loop label 
an exception?

```
func foo() {
ok := true
// Why is the loop label unindented backwards to the left?
Loop:
for {
switch {
case ok:
// Why is the loop label capitalized?
break Loop
}
}
}
```

Thanks in advance to those who are ancient enough to share the story behind 
loop labels.

-- 
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 this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/c2bfd4c3-4a0e-4a53-b8a7-d700543c4ef0n%40googlegroups.com.


[go-nuts] Re: Offline version of A Tour of Go

2023-09-26 Thread awaw
Thanks all for the instructions.
I was initially thinking something closer to a single file like PDF.
However, I might get away with a web server, too. Thanks

On Tuesday, 26 September 2023 at 22:22:41 UTC+8 Pankaj Jangid wrote:

> go install golang.org/x/website/tour@latest
>
> On Tuesday, 26 September 2023 at 11:59:57 UTC+5:30 王富民awaw wrote:
>
>> Hi Friends of Go
>>
>> Is there an offline version of A Tour of Go?
>> Could be in PDF or Powerpoint or preferably Go's beautiful present format.
>>
>> A quick Google search didn't reveal anything relevant.
>> Thanks in advance.
>>
>

-- 
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 this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/5cd55121-8bb1-4e2a-bad5-c7f7675654a7n%40googlegroups.com.


[go-nuts] Offline version of A Tour of Go

2023-09-26 Thread awaw
Hi Friends of Go

Is there an offline version of A Tour of Go?
Could be in PDF or Powerpoint or preferably Go's beautiful present format.

A quick Google search didn't reveal anything relevant.
Thanks in advance.

-- 
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 this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/65d30564-2fb2-4f1f-9bc3-bfdd159b2febn%40googlegroups.com.


[go-nuts] how to diagnose slow build

2023-06-29 Thread awaw
My builds have been very slow recently and I want to know why is `go build` 
so slow for me.
Is it due to reading disks or something else?

What is the recommended way of profiling/debugging `go build`?

I know that the `-x` flag prints detailed information of `go build` but it 
doesn't tell where is time spent.
I am familiar with profiling ordinary Go programs with pprof, but how can I 
apply it to `go build`.
An extensive search returned very few information as it hard to come up 
with a query for profiling `go build`, not profiling ordinary Go programs 
nor info about the `build` command itself.

Thanks

-- 
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 this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e8ebf97b-1294-427e-878a-a359f673794cn%40googlegroups.com.