Re: [go-nuts] encoding/asn1 I can't Marshal a struct with pointer members

2024-04-27 Thread Jan Mercl
On Sun, Apr 28, 2024, 03:03 J Liu <8859210...@gmail.com> wrote:

> My program is like this:
>
> type Girl struct {
>  Name string
>  Age  int
>  }
>
>  type Person struct {
>  girl *Girl
>  job string
>  }
>
>
> What should I do to Marshal 'Person'?
>


I think you need to export the fields, the same way like the Girl struct
have them exported, ie. by making the first character of the names upper
case.

hth

-- 
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/CAA40n-W72jqdGZSKvNvkj0V1DDuJLe3GczjeOZAKAEQGU6hD2A%40mail.gmail.com.


Re: [go-nuts] Is golang.org/x/text/message's Printer thread safe?

2024-04-22 Thread Jan Mercl
On Mon, Apr 22, 2024 at 11:23 AM Xiangrong Fang  wrote:

> Is golang.org/x/text/message's *message.Printer safe to use in goroutines?

I don't know, but usually things are safe for concurrent use by
multiple goroutines only when explicitly documented as such.

-- 
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/CAA40n-X%2B88yorR_bnRLkzb6Ys_Ne3nA-aw_PvdNrR_U10YC_oA%40mail.gmail.com.


Re: [go-nuts] Nillable basic types?

2024-03-18 Thread Jan Mercl
On Mon, Mar 18, 2024 at 4:41 AM Daniel Lepage  wrote:

> This change would be entirely backward-compatible ...

Let's consider, for example, the type uint8, aka byte. A variable of
type byte is specified* to occupy 8 bits of memory and has 256
possible values. To represent all those values and the new possibility
of the value being nil, we need 257 distinct values. But that does not
fit 8 in bits anymore. However, changing the size and/or the bit
representation of such a variable is observable, making it not
backwards-compatible.


*: From https://go.dev/ref/spec#Numeric_types:


The value of an n-bit integer is n bits wide and represented using
two's complement arithmetic.


-- 
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/CAA40n-XCMSmhEDGL04NfhOVpexG3GCDA0Vj2dq138pWJVSBnwA%40mail.gmail.com.


Re: [go-nuts] GO111MODULE=off go get deprecated?

2024-03-07 Thread Jan Mercl
On Sun, Mar 3, 2024 at 10:25 PM Jeffery Carr  wrote:

> Has this been deprecated or maybe it is broken in debian sid, but:
>
> bash$ GO111MODULE=off go get -v go.wit.com/apps/test
> go: modules disabled by GO111MODULE=off; see 'go help modules'
> basj$ go version
> go version go1.22.0 linux/amd64
>
> this doesn't work anymore. Also, 'go help modules' is less than helpful.
>
> Is there some other way to download the actual sourcecode into
~/go/src/mything/ anymore?

One can get a somehow similar effect using 'auto' instead of 'off':

jnml@e5-1650:~/tmp/get$ ls -la
total 8
drwxr-xr-x 2 jnml jnml 4096 Mar  7 11:18 .
drwxr-xr-x 6 jnml jnml 4096 Mar  7 11:18 ..
jnml@e5-1650:~/tmp/get$ GOPATH=$(pwd) GO111MODULE=off go get -v
modernc.org/sqlite
go: modules disabled by GO111MODULE=off; see 'go help modules'
jnml@e5-1650:~/tmp/get$ GOPATH=$(pwd) GO111MODULE=auto go get -v
modernc.org/sqlite
go: downloading modernc.org/sqlite v1.29.2
go: downloading modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6
go: downloading golang.org/x/sys v0.16.0
go: downloading modernc.org/libc v1.41.0
go: downloading modernc.org/token v1.1.0
go: downloading modernc.org/mathutil v1.6.0
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading github.com/hashicorp/golang-lru/v2 v2.0.7
go: downloading modernc.org/strutil v1.2.0
go: downloading github.com/remyoudompheng/bigfft
v0.0.0-20230129092748-24d4a6f8daec
go: downloading github.com/google/uuid v1.3.0
go: downloading github.com/ncruces/go-strftime v0.1.9
go: downloading github.com/mattn/go-isatty v0.0.16
go: downloading modernc.org/memory v1.7.2
jnml@e5-1650:~/tmp/get$ ls pkg/mod/
cache  github.com  golang.org  modernc.org
jnml@e5-1650:~/tmp/get$  go version
go version go1.22.0 linux/amd64
jnml@e5-1650:~/tmp/get$

HTH

-- 
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/CAA40n-UxFxrbrgZ%3Dn-hXYrrODjwDVX9uq995BWWLkjSf3G0XsQ%40mail.gmail.com.


Re: [go-nuts] Enums, Go1 and proposals

2024-03-04 Thread Jan Mercl
On Mon, Mar 4, 2024 at 6:19 PM Jeremy French  wrote:

> More, to prevent PrintMonth(14), which the function would have to check for 
> and either return an error or panic, since there is no meaningful output.  In 
> fact, it's fairly easy to see, even in this case, where the PrintMonth 
> signature would have to return an error, when that is pretty much the only 
> case where it would need to.  With an enum as an input parameter, the 
> PrintMonth() function would not need to have the error return value.  It's 
> the same type of philosophy around interfaces.  If you accept as an input 
> parameter an interface that has a PrintMonth() function, then you don't have 
> to double check that the passed struct/object has a PrintMonth() function. 
> You can just use it.

The static type of an interface can be verified at compile time. The
value of a variable of an enum type (or a Pascal-like subrange) type,
cannot be verified at compile time in the general case. You would have
to add features Go does not have (like variable immutability) and/or
restrict some features for enum types that Go does have (like taking
address and using unsafe). Neither looks to me very probable, at least
in a short time.

Those values can be however checked at runtime, similarly to
array/slice index bounds checking. For subrange-like enums it's rather
cheap and can be often eliminated. General, sparse-valued enums are
commonly too expensive to check at runtime for the compiler. to insert
them automatically.

-- 
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/CAA40n-X3B8je11%3DmZ98UBwWLAVkmOB-LweJCd_QU5xVqd%3Duiqg%40mail.gmail.com.


Re: [go-nuts] Enums, Go1 and proposals

2024-03-04 Thread Jan Mercl
On Mon, Mar 4, 2024 at 4:19 PM Jeremy French  wrote:

> It's checked at compile-time rather than run time.

That requires immutability of variables of enum type. Go does not
support immutable variables.

-- 
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/CAA40n-VuzKbH%2BztAMGqS867a0KqpE-v7t58dWMCJBdt1PDZ0Zg%40mail.gmail.com.


Re: [go-nuts] Equality of interface of an empty struct - why?

2024-02-26 Thread Jan Mercl
On Tue, Feb 27, 2024 at 6:20 AM tapi...@gmail.com  wrote:

> From common sense, this is an obvious bug. But the spec is indeed not clear 
> enough.
> It doesn't state whether or not comparisons of pointers to two distinct 
> zero-size variables should be consistent in a run session.
> Though, from common sense, it should.

"Pointers to distinct zero-size variables may or may not be equal."

The outcome is specified to be not predictable. Expecting consistency
means the outcome should be, or eventually become, predictable. That's
the opposite of what the specs say.

-- 
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/CAA40n-XN-U8JrVJ0uJqbftk2fNSiHEoDu7qsOde-FwHc5voSVg%40mail.gmail.com.


Re: [go-nuts] Unhappy with the official generics tutorial

2024-02-22 Thread Jan Mercl
On Thu, Feb 22, 2024 at 10:06 AM 'Carla Pfaff' via golang-nuts
 wrote:

> This omission is notable considering "any" is among the most frequently used 
> constraints in writing generic code.

Interesting to know, I'd naively guess the opposite. Can you please
share the source data set? 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 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/CAA40n-W2%3DBysk7OHi_OqV%3DM3EO_67JMyy5DjhBEpW7Gaa8FeKw%40mail.gmail.com.


Re: [go-nuts] Ghost/indirect dependency on a custom package

2024-02-20 Thread Jan Mercl
On Tue, Feb 20, 2024 at 11:07 AM Peter Bočan  wrote:

> Is there a way to debug this? Is there a way to step over the initialisation 
> order?

I try to get help from '$ go mod graph' in similar investigations.

-- 
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/CAA40n-X8cnxAWpAJY%2BLq%3D4kvRtMi%2Badv6ahQ9G5z4_0A0SnctA%40mail.gmail.com.


Re: [go-nuts] big int panic on text conversion

2024-02-14 Thread Jan Mercl
On Wed, Feb 14, 2024 at 12:14 PM 'Dan Kortschak' via golang-nuts
 wrote:

> Given that this can happen without a race or unsafe modifications it
> might be worth filing a issue for.

I think this is expected. Quoting from the big.Int docs
https://pkg.go.dev/math/big#Int


To "copy" an Int value, an existing (or newly allocated) Int must be
set to a new value using the Int.Set method; shallow copies of Ints
are not supported and may lead to errors.


But OP's 'b := *a' is creating a shallow copy.

-- 
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/CAA40n-XGCwJHgqj7nMnkoF_sJcrdA3DsbM8OuVmmPNgqg7ZBXg%40mail.gmail.com.


Re: [go-nuts] How could we emulate condition variables using Go channels only?

2024-01-12 Thread Jan Mercl
On Fri, Jan 12, 2024 at 7:57 PM Rochus Keller  wrote:

> Here is the full question with examples (though meanwhile closed as usual in 
> recent times on stackoverflow, so answer here please): 
> https://stackoverflow.com/questions/77802102/mutex-and-condition-variables-in-go-without-using-the-sync-package
>
> This is a conceptual question based on the duality of monitors and message 
> passing. My goal is to see and be able to experiment with a correct and 
> complete example of a mutex with condition variables in Go which only use Go 
> channels for implementation, as a proof of concept. Only then we can discuss 
> how far it makes sense from an engineering standpoint.
>

Something like this? https://go.dev/play/p/_H3kFjprAGG

-- 
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/CAA40n-UWgi%3D8OvAvs1gR3kudxxQFNfnFgDNLb3OUq-8iLAGrXw%40mail.gmail.com.


Re: [go-nuts] Re: Rendering fonts in Go

2024-01-12 Thread Jan Mercl
On Fri, Jan 12, 2024 at 12:34 PM 'Brian Candler' via golang-nuts
 wrote:

> At worst, it may possible to compile C into Go. It sounds mad, but I believe 
> SQLite has been ported to pure Go this way.

Challenge accepted: https://pkg.go.dev/modernc.org/libfreetype

-- 
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/CAA40n-URgHjw%3DarU1NZAo9XfQ%3DJ0qDwMiFZHPE-94NDuhQx%2B%2Bw%40mail.gmail.com.


Re: [go-nuts] Re: A global panic handler for crash reporting

2023-12-26 Thread Jan Mercl
On Tue, Dec 26, 2023 at 9:12 AM Gergely Brautigam  wrote:

> If you have a top level recover in you main, it doesn't matter where the 
> panic happens, you'll capture it. Even in third party library.

Iff the panic occurs in the same goroutine where the defer is. Every
go statement starts a new goroutine that is not affected by defer
statement(s) in other goroutines.

-- 
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/CAA40n-V3eEVdouxr-uLiTvQSqNxmBSTCdpofUJ9rfFpDKB7Gpw%40mail.gmail.com.


Re: [go-nuts] circular package dependency between golang.org/x/mod and golang.org/x/tools

2023-12-19 Thread Jan Mercl
On Tue, Dec 19, 2023 at 9:37 PM Nathan Lacey  wrote:

> I noticed that we have a circular dependency between golang.org/x/mod and 
> golang.org/x/tools
>
>  golang.org/x/mod  zip/zip_test.go includes golang.org/x/tools
> I think we could get rid of the circular package dependency by changing that 
> unit test to remove the dependency to tools/txtar .

But why? What's the motivation to remove the cycle?

-- 
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/CAA40n-URNGfDo34j4Ui-wvCiYjQysfMoJii%2B1m3CP_U85c0ezA%40mail.gmail.com.


Re: [go-nuts] Need help running "go get" on self hosted git server

2023-12-18 Thread Jan Mercl
On Mon, Dec 18, 2023 at 2:19 PM Brijesh Wawdhane 
wrote:

> I added a go-import meta tag to my git server's website on the repo page
and it looks like
>
> https://brijesh.dev/kairos.git;>
>
> but when I try running "go get brijesh.dev/kairos" I get an error saying
'go: unrecognized import path "brijesh.dev/kairos": reading
https://brijesh.dev/kairos?go-get=1: 404 Not Found'
>
> it is probably because it is looking at
https://brijesh.dev/kairos?go-get=1(which is invalid) and not
https://brijesh.dev/kairos.git?go-get=1(the correct address) even though it
the url is with .git in the go-import tag

I'm not sure what is correct, but FTR this redirector service reports the
redirected URL without the .git suffix and it works as intended:


jnml@3900x:~/tmp$ wget modernc.org/sqlite
--2023-12-18 14:57:40--  http://modernc.org/sqlite
Resolving modernc.org (modernc.org)... 216.239.34.21, 216.239.32.21,
216.239.38.21, ...
Connecting to modernc.org (modernc.org)|216.239.34.21|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://modernc.org/sqlite [following]
--2023-12-18 14:57:40--  https://modernc.org/sqlite
Connecting to modernc.org (modernc.org)|216.239.34.21|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 577 [text/html]
Saving to: 'sqlite'

sqlite
 
100%[=>]
577  --.-KB/sin 0s

2023-12-18 14:57:41 (20.6 MB/s) - 'sqlite' saved [577/577]

jnml@3900x:~/tmp$ cat sqlite




https://gitlab.com/cznic/sqlite;>
https://gitlab.com/cznic/sqlite/blob/master{/dir}
https://gitlab.com/cznic/sqlite/blob/master{/dir}/{file}#L{line};>
https://godoc.org/modernc.org/sqlite;>


Redirecting to docs at https://godoc.org/modernc.org/sqlite;>
godoc.org/modernc.org/sqlite...


jnml@3900x:~/tmp$


-- 
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/CAA40n-We%3D%3Dsm812yorAgKgH8hZmM2Akm3P%2BpzpJR9dLD%2BfNV6w%40mail.gmail.com.


Re: [go-nuts] detecting deleted file that is still open and appending without error in Go?

2023-12-10 Thread Jan Mercl
On Sun, Dec 10, 2023 at 8:34 PM Jason E. Aten  wrote:

> I noticed that the binary log was not growing, and its update timestamp was 
> not changing.

I think the file was still growing as intended. It was only no more
associated with the _new_ entry/name in the directory. I'm pointing it
out because it means no data is being lost until the FD of the
no-more-linked file is closed.

IOW, I think observing the file "no more growing" and "its time stamp
not updating" is now observing a different file than the one you're
writing the log to. That also means os.Stat("some_name") cannot help.
The "truth" is available at (*os.File).Stat().

HTH

-j

-- 
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/CAA40n-X-PkBNARpYS6aXMMh7CCE5-U_T48fOtPR4EU77t0s8Cg%40mail.gmail.com.


Re: [go-nuts] detecting deleted file that is still open and appending without error in Go?

2023-12-10 Thread Jan Mercl
On Sun, Dec 10, 2023 at 5:41 PM Jason E. Aten  wrote:

> My question is: is there a way to have the Go process detect if the file it 
> is writing to has been deleted by another process (git in this case) so that 
> attempting to append to the file is no longer effective?

It is effective and [most] operations on the file continue to work as
usual. "Removing" a file, like in `os.Remove` is just removing one
reference to it. Only when the reference count drops to zero is the
file deleted.

This is, AFAIK, how nixes work and it's IMO actually a neat feature.
It enables, for example, updating files without disrupting processes
that have those files opened. Less advanced operating systems, to
achieve the same effect, have to reboot etc.

-- 
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/CAA40n-VZDOdwMOqqmAc-RgpGyNkOi0LvyFR%2BKbzem4PqNNwrYQ%40mail.gmail.com.


Re: [go-nuts] Go ARM

2023-11-15 Thread Jan Mercl
On Wed, Nov 15, 2023 at 9:59 PM Stephen Illingworth
 wrote:
>
> That works better although not perfectly for my purposes. More work required 
> from me.
>
> I'm curious though, about the -marm flag. How can I remove it from the 
> GOGCCFLAGS variable? Or are we saying we can't use the aarch64 compiler in 
> conjunction with cgo?

Please share the output of '$ go version' and the output of '$ gcc
-dumpmachine'.

-- 
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/CAA40n-XALZibTeEh9erHvN74Wa_rwF%3Dqwb9Jgz15HadK_8hsxQ%40mail.gmail.com.


Re: [go-nuts] Go ARM

2023-11-15 Thread Jan Mercl
On Wed, Nov 15, 2023 at 8:30 PM Stephen Illingworth <
stephen.illingwo...@gmail.com> wrote:
> I'm trying to build a project on the Raspberry Pi, natively.
>
> Using "go env" I can see that Go has the following value for GOGCCFLAGS
>
> GOGCCFLAGS='-fPIC -marm -Wl,--no-gc-sections -fmessage-length=0
-ffile-prefix-map=/tmp/go-build745518569=/tmp/go-build
-gno-record-gcc-switches'
>
> However, the native compiler (gcc 12.2) does not have the -marm flag. The
compilation of the project fails.

>From the above I guess you might be running gcc for aarch64 as the arm
version accepts the -marm flag here:

jnml@pi32:~/tmp/gcc$ go version
go version go1.21.4 linux/arm
jnml@pi32:~/tmp/gcc$ cat main.c
#include 

int main() {
printf("Hello, world!\n");
}
jnml@pi32:~/tmp/gcc$ rm -f a.out ; gcc -marm main.c && ./a.out && echo ok
Hello, world!
ok
jnml@pi32:~/tmp/gcc$ gcc --version
gcc (Raspbian 10.2.1-6+rpi1) 10.2.1 20210110
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

jnml@pi32:~/tmp/gcc$

I tried the solution from
https://jensd.be/1126/linux/cross-compiling-for-arm-or-aarch64-on-debian-or-ubuntu
and it seems to work fine:

jnml@pi64:~/tmp/gcc$ jnml@pi64:~/tmp/gcc$ go version
go version go1.21.4 linux/arm64
jnml@pi64:~/tmp/gcc$ cat main.c
#include 

int main() {
printf("Hello, world!\n");
}
jnml@pi64:~/tmp/gcc$ rm -f a.out ; gcc main.c && ./a.out && echo ok
Hello, world!
ok
jnml@pi64:~/tmp/gcc$ rm -f a.out ; gcc -marm main.c && ./a.out && echo ok
gcc: error: unrecognized command-line option ‘-marm’
jnml@pi64:~/tmp/gcc$ sudo apt install gcc-arm-linux-gnueabi
binutils-arm-linux-gnueabi
...
jnml@pi64:~/tmp/gcc$ rm -f a.out ; arm-linux-gnueabi-gcc -marm main.c &&
file a.out
a.out: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically
linked, interpreter /lib/ld-linux.so.3,
BuildID[sha1]=2191a16290d46b039bfae26fd5918106dff99749, for GNU/Linux
3.2.0, not stripped
jnml@pi64:~/tmp/gcc$

HTH

-- 
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/CAA40n-UeuRqwty-w8Z%3D1%2B3rEt1xJqKYc%3DELCWK4DjUOzjuCRvw%40mail.gmail.com.


Re: [go-nuts] ldflags -X

2023-11-08 Thread Jan Mercl
On Wed, Nov 8, 2023 at 4:01 PM Stephen Illingworth
 wrote:

> I would have expected the "main.A" string to require the same form. But 
> either way, that's the correct solution.

It is the correct form. Package main cannot be imported and has a
special import path. Though I don't know where it is documented.

-- 
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/CAA40n-XswSrWE%2BwdEMy9PdVazFBKm2%2Bt8CGw1z9Z5UAMCDoUNw%40mail.gmail.com.


Re: [go-nuts] ldflags -X

2023-11-08 Thread Jan Mercl
On Wed, Nov 8, 2023 at 1:35 PM Stephen Illingworth <
stephen.illingwo...@gmail.com> wrote:
>
> Hello,
>
> I'm trying to use the -X ldflag to set a string at compile time. I can do
this successfully if the string is in the main package but it does not work
if the string is in a subpackage.
>
> For illustration purposes, I have prepared a simple test project
>
> https://github.com/JetSetIlly/ldflags_X_test
>
> The build.sh file contains the build string. It contains one useful line,
which I'll repeat it here:
>
> go build -ldflags "-X 'main.A=foo' -X 'sub.B=bar'"
>
> When built, the main function will print out the A string correctly but
the B string is unset.
>
> What am I doing wrong?

The second -X flag does not have the documented form, see
https://pkg.go.dev/cmd/link.

jnml@3900x:~/src/x/ldflags_X_test$ ls -l
total 16
-rwxr-xr-x 1 jnml jnml  101 Nov  8 13:47 build.sh
-rw-r--r-- 1 jnml jnml   55 Nov  8 13:47 go.mod
-rw-r--r-- 1 jnml jnml  144 Nov  8 13:47 main.go
drwxr-xr-x 2 jnml jnml 4096 Nov  8 13:47 sub
jnml@3900x:~/src/x/ldflags_X_test$ git diff
diff --git a/build.sh b/build.sh
index db86e35..0185e5e 100755
--- a/build.sh
+++ b/build.sh
@@ -1,3 +1,3 @@
 #!/bin/bash

-go build -ldflags "-X 'main.A=foo' -X 'sub.B=bar'"
+go build -ldflags "-X 'main.A=foo' -X '
github.com/JetSetIlly/ldflags_X_test/sub.B=bar'"
jnml@3900x:~/src/x/ldflags_X_test$ ./build.sh && ./ldflags_X_test
foo
bar
jnml@3900x:~/src/x/ldflags_X_test$

-- 
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/CAA40n-XP7%2BiTS_aCR88%2Buuzi5Xo7ypHJeNDkczvHJUtzpjrE3Q%40mail.gmail.com.


Re: [go-nuts] Re: Why causes []any trouble in type equations?

2023-10-11 Thread Jan Mercl
On Wed, Oct 11, 2023 at 8:11 PM Torsten Bronger
 wrote:

> Then, all boils down to the fact that you can’t pass []float64 as an
> []any.  To be honest, I still don’t fully understand why this is
> forbidden, so I just accept that the language does not allow it.

It's the same reason why one cannot pass, say []byte as an []int. The
backing arrays of the two slices have incompatible memory layouts. To
make it work the compiler would have to inject code like
(schematically)

var tmp []int
for i, v := range byteSlice {
   tmp = append(tmp, v)
}
   callTheFuntion(tmp)

It is doable but it has a cost which the language designers preferred
not to hide.

-- 
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/CAA40n-Vp%2B22PhXxxYBwvj77G3zFVEStSzr1%3DTsCuALYZS-%2BHQg%40mail.gmail.com.


Re: [go-nuts] how do you compie and link a go main with an assembly code file?

2023-10-09 Thread Jan Mercl
On Mon, Oct 9, 2023 at 6:02 PM Peter Riemenschneider  wrote:

Just '$ go build' as usual, but one must declare the asm function:
https://go.dev/play/p/KySqFvCVz_T

-- 
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/CAA40n-UEhabq5%3DQs5oxYZeL4RW%2BLDfbBap1tzhh5fwTdba7EJA%40mail.gmail.com.


Re: [go-nuts] The docs for secretbox seem very wrong

2023-10-09 Thread Jan Mercl
On Mon, Oct 9, 2023 at 3:46 PM Dean Schulze  wrote:

> If the docs are correct, how do you append to nil?

https://go.dev/play/p/WY0Bycj-_Tn

-- 
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/CAA40n-WtCRNSp8eLQxDfhjhKBhR4UPdciNPNaS9Oj7v1EdBD-Q%40mail.gmail.com.


Re: [go-nuts] Help understanding slices, variable arguments, and passing slices to functions

2023-09-25 Thread Jan Mercl
On Mon, Sep 25, 2023 at 1:57 PM Andrew Pillar  wrote:

A nice discussion of slices can be found for example here:
https://research.swtch.com/godata

tl;dr: Yes, slices are passed by value (everything in Go is passed by
value), but a slice does not contain the backing array, only a pointer
to it.

-j

-- 
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/CAA40n-XOM_j8wOoK_2k3LQmA23AyX23fMZB3yx48eAGe9pNGGQ%40mail.gmail.com.


Re: [go-nuts] Re: Weird error when trying to fetch a module.

2023-09-15 Thread Jan Mercl
On Fri, Sep 15, 2023 at 10:31 AM 'Jim Idle' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> The go.mod at the root was one thing that might work, but it will cause
the entire repo to be pulled in so the tag will still have to be sec/go/
etc.

tl;dr: Putting a go.mod in the repository root has no additional costs for
the repo users.

I was curious if the entire repo would be pulled, that would surprise me.
Turns out that's not the case.


0:jnml@e5-1650:/tmp/mod$ ls -la
total 500
drwxr-xr-x   2 jnml jnml   4096 Sep 15 10:47 .
drwxrwxrwt 164 root root 487424 Sep 15 10:49 ..
-rw-r--r--   1 jnml jnml937 Sep 15 10:45 go.mod
-rw-r--r--   1 jnml jnml   5461 Sep 15 10:45 go.sum
-rw-r--r--   1 jnml jnml 83 Sep 15 10:45 main.go
0:jnml@e5-1650:/tmp/mod$ cat go.mod
module example.com/mod

go 1.21.1

require modernc.org/ccgo/v4 v4.0.0

require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/kballard/go-shellquote
v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec
// indirect
golang.org/x/mod v0.11.0 // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/tools v0.10.0 // indirect
lukechampine.com/uint128 v1.2.0 // indirect
modernc.org/cc/v3 v3.41.0 // indirect
modernc.org/cc/v4 v4.14.2 // indirect
modernc.org/ccgo/v3 v3.16.15 // indirect
modernc.org/gc/v2 v2.3.0 // indirect
modernc.org/libc v1.24.1 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.7.0 // indirect
modernc.org/opt v0.1.3 // indirect
modernc.org/strutil v1.2.0 // indirect
modernc.org/token v1.1.0 // indirect
)
0:jnml@e5-1650:/tmp/mod$ cat main.go
package main

import "modernc.org/ccgo/v4"

func main() {
println({})
}
0:jnml@e5-1650:/tmp/mod$ go clean -cache -modcache -testcache ; sudo rm -rf
~/pkg ~/.cache/go-build/
0:jnml@e5-1650:/tmp/mod$ go build -v -x |& grep 'ccgo.*\.zip'
# get https://proxy.golang.org/modernc.org/ccgo/v4/@v/v4.0.0.zip
# get https://proxy.golang.org/modernc.org/ccgo/v4/@v/v4.0.0.zip: 200 OK
(0.111s)
# get https://proxy.golang.org/modernc.org/ccgo/v3/@v/v3.16.15.zip
# get https://proxy.golang.org/modernc.org/ccgo/v3/@v/v3.16.15.zip: 200 OK
(0.032s)
0:jnml@e5-1650:/tmp/mod$


Note: ccgo/v4 depends on ccgo/v3 but that's not relevant to this experiment.

-j

-- 
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/CAA40n-UbYxMCJ8T6QMApV1xme9C9JNR3EjRjh_CT0xoyoU1Wew%40mail.gmail.com.


Re: [go-nuts] How ignore a subdirectory

2023-09-13 Thread Jan Mercl
On Wed, Sep 13, 2023 at 12:25 PM John Souvestre  wrote:
> I did try that also.  I get this error message:
>
> CreateFile *.go: The filename, directory name, or volume label syntax
is incorrect.

Sorry, I'm not familiar with Windows and only TIL cmd.exe does not expand
globs. I suggest to install WSL and try something like

C:\>bash -c 'gofmt *.go'

HTH

-- 
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/CAA40n-WiqO8BsKxi3wB%2Bg6L8GgZQSqCirT-3pHS%2BVND2%2BXw1kQ%40mail.gmail.com.


Re: [go-nuts] How ignore a subdirectory

2023-09-13 Thread Jan Mercl
On Wed, Sep 13, 2023 at 5:47 AM 'John Souvestre' via golang-nuts
 wrote:

> I’m trying to run gofmt on all of the .go files in a directory, but not any 
> subdirectories.

$ gofmt *.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/CAA40n-WiBpBdhHrb2t%3Duf0Ooajk%2BfALeWQEYfj%3D2rEADTOh8jw%40mail.gmail.com.


Re: [go-nuts] How to constrain an integral type's values

2023-09-08 Thread Jan Mercl
On Fri, Sep 8, 2023 at 9:24 AM 'Mark' via golang-nuts
 wrote:

> Is there a compile-time solution for this that I've missed?

No. Go does not have enum types.

-- 
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/CAA40n-Xt4awDMhsKvL_EQZzN_B7O1pzss95PZC6xaufssQuoYA%40mail.gmail.com.


Re: [go-nuts] Re: Best IDE for GO ?

2023-08-26 Thread Jan Mercl
On Sat, Aug 26, 2023 at 2:33 PM Jason E. Aten  wrote:
>
> Is there any IDE that allows you to jump through a stack trace like emacs 
> does?

I think many code editors can do that, for example vim:
https://vim.fandom.com/wiki/Open_file_under_cursor

-- 
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/CAA40n-VY54WdM2bC8ev-SWdXSpAJPpXyadea81xsmUJEuqcvxQ%40mail.gmail.com.


Re: [go-nuts] Best IDE for GO ?

2023-08-19 Thread Jan Mercl
On Sat, Aug 19, 2023 at 10:06 PM Christian Stewart
 wrote:

> Autocomplete and a go language server (gopls) add a ton of speed because you 
> don't need to look up the docs for function and variable names. And go to 
> definition improves speed navigating code significantly.

- Using autocomplete and go-to-definiton does not require VSCode or
any other IDE.
- I do use autocomplete and go-to-definition. When I said I use no
IDE, that does not mean I don't use those features.
- The speed of typing/inputting code is overally a rather negligible
factor of the total time cost of developing/debugging and maintaining
any non-toy project. IOW, it's not a significant metric of
productivity.

> But vim-go can do both, so why not just use it?

Because I use govim? ;-)

(But not for my large projects, gopls chokes on them still too often
to tolerate it.)

-- 
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/CAA40n-XusymW6gb5OnDa_7QWAWPFSkwKYQMYUm-d7419EZ%2BGkQ%40mail.gmail.com.


Re: [go-nuts] Best IDE for GO ?

2023-08-19 Thread Jan Mercl
On Sat, Aug 19, 2023 at 9:42 PM Robert Engels  wrote:

> I guarantee that two developers of equal competence - the one with a powerful 
> IDE will outperform the other using a text editor with syntax highlighting 
> (but come on that is a crutch a real developer doesn’t need) by 2-10x 
> depending on the task.

Guarantee. You keep saying that word, but ...

-- 
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/CAA40n-XMxfExZsS8ih9vireQjefpUqWZ36NrZ6-3mfX_9Vehgw%40mail.gmail.com.


Re: [go-nuts] Best IDE for GO ?

2023-08-19 Thread Jan Mercl
On Sat, Aug 19, 2023 at 11:27 AM alex-coder  wrote:

> Gophers, may be there is another place where I should look for IDE for GO ?

Unix is my IDE and vim is its prophet.

IME IDEs make programmers write low quality code while enjoying the
illusion of being "more productive".

-- 
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/CAA40n-V7ZjnyQeUuTx9S5Xj5cMhroNkMqX3cFCaTJG86zN8M2Q%40mail.gmail.com.


Re: [go-nuts] Re: Go 1.21.0 is released

2023-08-09 Thread Jan Mercl
On Wed, Aug 9, 2023, 09:12 Marcello H  wrote:

> https://go.dev/dl/go1.21.0.windows-arm64.zip
>
> It is found when you click on "Other Ports"


Thanks. I may have a false memory of always finding the windows/arm64 port
beside the windows/amd64 one in the same section.

-j

-- 
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/CAA40n-VJY1UABea%3D%3D9yTC9o3PPgnQtXQsP4F%2BLdBaMvT9g2Umg%40mail.gmail.com.


[go-nuts] Re: Go 1.21.0 is released

2023-08-08 Thread Jan Mercl
On Tue, Aug 8, 2023 at 5:24 PM  wrote:

> We have just released Go 1.21.0.
>
> To find out what has changed in Go 1.21, read the release notes:
> https://go.dev/doc/go1.21
>
> You can download binary and source distributions from our download page:
> https://go.dev/dl/#go1.21.0

It looks like the download page is missing Go 1.21.0 for windows/arm64.

-- 
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/CAA40n-UF3JUeVNv9qhWqgjpyLqBDpn%2BDqkLnZKD01YNFkvf_WA%40mail.gmail.com.


Re: [go-nuts] Re: How to convert an svg to a png (or gif) image?

2023-08-04 Thread Jan Mercl
On Fri, Aug 4, 2023 at 1:22 PM Brian Candler  wrote:

> Also there's a project which compiles C code to Go - ISTR it was used to 
> build a pure Go version of Sqlite.  Presumably the same approach could be 
> applied to an image processing library.
>
> https://twitter.com/bradfitz/status/855271867162083329?lang=en
> https://groups.google.com/g/golang-nuts/c/QDEczMhlQBU/m/4lCn2kP0AwAJ
> https://github.com/elliotchance/c2go

ccgo/v3 is being slowly phased out. ccgo/v4 is not yet released, but
maybe it can already transpile a C SVG to PNG code base and I'd like
to try that to at least know where it fails.

A quick search found no such C code, but that might be my fault. Does
anyone know about a pure C SVG to PNG lib/program?

-j

-- 
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/CAA40n-WLtSqLRmsYvCX1UtdnxhtPJEdDR0T%3DoSg8EXZUkPHDVw%40mail.gmail.com.


Re: [go-nuts] Re: Error handling

2023-08-01 Thread Jan Mercl
On Tue, Aug 1, 2023 at 1:47 AM DrGo  wrote:

> The verbosity of error handling is the number one concern for Go developers 
> in the most recent survey.

That says something about those developers, about their preferences,
opinions, taste etc and that it differs from what the Original
Language Designers (OLD™) preferred.

It has close to zero bits of information which preferences are the
better ones. It's a subjective category anyway.

> So there is a need for doing something about it..

And here's IMO the mistake. You may feel the need, Joe and Mary may
not. It's ok to have preferences. It's ok for preferences to be
different. It does not mean there's a need to change anything. Of
course, you can decide that following the preferences of a majority of
developers is a rational move.

I claim it a fallacy. A big one. Let me not joke about billion flies,
but the fact is - language designers are few and far between while
developers come in heaps. And let's be honest. Most developers write
horrible code, me included. Maybe you're the rare exception, congrats
then. But the majority of us are just the ordinary, average coders for
hire. There are deadlines to meet, bills to pay, project mis-managers
getting into the way etc. We have all experienced that, didn't we?

I, for one learned to pay much more attention to what language
designers do and say. Sometimes I agree, sometime I don't. But I
believe one can, in essence, ignore what the majority of developers
thinks about it. Actually, I think the majority of developers is wrong
more often than the, most of the time silent, minority.

-j

-- 
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/CAA40n-UNPFRR55YYJgWs34jh38p1zf61PpZaWFGiH2_khv1kbg%40mail.gmail.com.


Re: [go-nuts] [go test] pure Test Classes.

2023-07-26 Thread Jan Mercl
On Wed, Jul 26, 2023 at 9:44 AM sumith s  wrote:

> Currently, we do not have pure Test Classes defined by us. We are using 
> Golang specific Test Class structure. Each FILENAME_test.go will have its own 
> test class under "Golang Test".
> I'm trying to define a  pure Test Classes. how can do that?

(Go does not have classes. Go has types and types may have methods attached.)

Anyway, please explain what you mean by "pure" in "pure Test Classes".

The go tool, when invoked like "go test" looks for functions in files
matching '.*_test.go', with name matching 'Test.*' and the signature
func(t *testing.T), "testing" being the stdlib package. Such functions
will be then executed automatically during the test.

It is of course possible to write any other kind of tests and invoke
them independently of the "go test" facility, using any preferred
method of doing so.

-- 
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/CAA40n-W4PGv00tUGs7SjmDrxecDdJJDNMwhCkdFbFWO5EYNzzA%40mail.gmail.com.


Re: [go-nuts] go package dating back to 2009

2023-07-25 Thread Jan Mercl
On Wed, Jul 26, 2023 at 12:32 AM Bravo Moua  wrote:

> For a fact, bytes, fmt, and packages in those category are from Satoshi 
> Nakamoto and myself.

Extraordinary claims require extraordinary evidence.

-- 
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/CAA40n-Xna5Zg-RRygLRquchVC4Z3945kjpE-Z69YBbskB-z0wg%40mail.gmail.com.


Re: [go-nuts] no way to pause `Listen` on net connections

2023-07-24 Thread Jan Mercl
On Mon, Jul 24, 2023 at 9:26 AM David N  wrote:

> Yup, this makes sense and should work, but I'm still surprised this can't be 
> entirely done in Golang.

Who says it's not possible? I'm not aware of a reason why the required
parts cannot be implemented in pure Go (+ syscalls + right permission
bits): https://git.netfilter.org/iptables/

Alternatively, if CGo is not a problem, libiptables is a thing.

-- 
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/CAA40n-XDMCHtzu2Hb4pV_rWapNozO4xmktODZZzqNk4M-gfHrw%40mail.gmail.com.


Re: [go-nuts] no way to pause `Listen` on net connections

2023-07-24 Thread Jan Mercl
On Mon, Jul 24, 2023 at 9:14 AM David N  wrote:

On Linux you may try fiddling with iptables, limitations apply:
https://stackoverflow.com/questions/44464617/stop-accepting-new-tcp-connections-without-dropping-any-existing-ones/44509993#44509993

-- 
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/CAA40n-XA8RtHBvhw9oE2S%3Dhfve%2BUOTwRr8w0zEJs6-9_YKSoVw%40mail.gmail.com.


Re: [go-nuts] testing whether two maps are the same object

2023-07-18 Thread Jan Mercl
On Tue, Jul 18, 2023 at 4:35 PM Jochen Voss  wrote:

> Is there a better way?

I have never been here and please don't do this:
https://go.dev/play/p/x4QYJubXMnQ

-- 
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/CAA40n-Vy94Z%3D2LxbtTYqKzsNetBFcK66nHg28SP3zO9QK6xV9A%40mail.gmail.com.


Re: [go-nuts] map type conversion

2023-07-16 Thread Jan Mercl
On Sun, Jul 16, 2023 at 6:02 PM Leonard Mittmann
 wrote:

> Hi everyone, I am wondering if there is efficient way to do the following 
> type conversion (without looping over the map):
>
> var m = map[uint]uint{ /*...*/ }
> type uintXXX uint
> // this does not work
> var m2 map[uintXXX]uintXXX = (map[uintXXX]uintXXX)(m)

Yes, AFAICT, the language specification does not allow such
conversion. The underlying types of uintXXX and uint are the same, so
a conversion between uintXXX and uint is allowed in certain
situations. However, the underlying types of map[uintXXX]uintXXX and
map[uint]uint and are different and thus the conversion is not
possible. Exact details available at
https://go.dev/ref/spec#Conversions.

A different question is - could the specs allow this particular
conversion? I guess probably yes. If you can think of a backwards
compatible specs change that relaxes the conversion rules and allows
this and does not have any bad side effects, it might be a good idea
to fill a proposal at the issue tracker. It will be considered, if not
already rejected before.

-- 
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/CAA40n-Wit7zW7QUDNJR%2BrujhokRxJ0e74xRFTGXX%2BtoNspVB8Q%40mail.gmail.com.


Re: [go-nuts] Why not return after calling http.Error()

2023-07-04 Thread Jan Mercl
On Tue, Jul 4, 2023 at 5:38 PM Gurunandan Bhat  wrote:

> Every example of http Handler that I have seen so far looks like this:
>
> func handleSomeRequest(w http.ResponseWriter, r *http.Request) {
>
> // do something that returns an error
> if err != nil {
> http.Error(w, "Something bad happened", http.SomeAppropriateStatus)
> }
>
> // do other things if there was no error above and finally
> w.Write(someBytes)
> }
>
> My question is: Assuming there is no point carrying on after "Something bad 
> happened" why don't we just return (after writing someBytes to w inside the 
> if error != nil if that is what is expected). I have never seen any code that 
> returns after calling Error(), and I wonder why.

>From the docs at https://pkg.go.dev/net/http#Error


It does not otherwise end the request; the caller should ensure no
further writes are done to w.


AFAICT you're right, correct handler code should return after calling
http.Error.

-- 
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/CAA40n-V3mw2S2hY%3DpnAG3axfE_PTV%2BC0CQPT8uF2dWBQw%2BQt%2Bg%40mail.gmail.com.


Re: [go-nuts] delve crashes in presence of a circular reference variable

2023-06-23 Thread Jan Mercl
On Fri, Jun 23, 2023 at 10:38 AM christoph...@gmail.com
 wrote:
>
> Here is the minimal example code causing delve 1.20.2 to crash with a stack 
> overflow
>
> func TestExample(t *testing.T)  {
> type pptr *pptr
> var p pptr
> p = 
> t.Error("hello")
> }
>
> Here is the stack trace

I guess you may get better feedback by issuing the report at
https://github.com/go-delve/delve/issues.

-- 
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/CAA40n-XYw2TN-QZOcBakTyRiQLmB5JsLthdQCEL%2BME45yP3HeQ%40mail.gmail.com.


Re: [go-nuts] Please consider voting to reopen Golang subreddit

2023-06-23 Thread Jan Mercl
On Fri, Jun 23, 2023 at 10:18 AM Axel Wagner
 wrote:

> Just for context, as not everyone seems to be aware: I was, in that sentence 
> you quoted, referring to examples like this
> https://www.reddit.com/r/ModCoord/comments/14eq8ip/the_entire_rmildlyinteresting_mod_team_has_just/
> This demonstrates that even with overwhelming support from the community (and 
> yes, in this example the modifier applies), the company overwrites those 
> wishes to shut down protest. There are a couple of other subreddits with 
> similar stories.
>
> So I was making the case to *provide* overwhelming support for the mods of 
> /r/golang, referring to precedent of other subreddits where that is 
> happening. Not claiming that they already have it.

Thanks for the added conext.

Anyone not liking Reddit is free to not visit the site. Anyone not
accepting the price for the API access is free to not buy it. It's
fine to vote by your visits and by your wallet. That's how the free
market works and it works well unless there's some monopoly. But
Reddit has no monopoly.

Protesters are free to protest. That's their respected right.
Protesters have no right to deny access to other users. That's my
right and I expect it to be equally respected.

PS: I'm paying $7/month to Reddit to have r/golang ad-free. May I ask
you for a refund? Thanks for your consideration.

-- 
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/CAA40n-UU-fvBis8XZuOobK_6wW44iOddAzni1KRF9udHH-ELtg%40mail.gmail.com.


Re: [go-nuts] Please consider voting to reopen Golang subreddit

2023-06-23 Thread Jan Mercl
On Fri, Jun 23, 2023 at 7:01 AM 'Axel Wagner' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> And even *when* they ask and get overwhelming backing from their
communities, ...

Latest poll results on r/golang as of now:

[image: image.png]

https://www.google.com/search?q=define+overwhelming

-- 
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/CAA40n-X6_qjcfuVX%2BaavgA2noKZib%3DBiyPJgh9d3Um_5k23G2Q%40mail.gmail.com.


Re: [go-nuts] Why is reflect.CanAddr() returning false in this case ?

2023-06-22 Thread Jan Mercl
On Thu, Jun 22, 2023 at 12:16 PM christoph...@gmail.com
 wrote:
>
> I'm trying to get the uintptr address of a value p for which I have the 
> reflect.Value so that I can compare it with the value obtained with 
> v.Pointer() when p is a pointer.
>
> Here is a simple recursive pointer example code showing what happens: 
> https://go.dev/play/p/pST8DierbXS
>
> It is a pointer to itself defined like this:
>
> type pptr *pptr
> var p pptr
> p = 
>
> The problem is that reflect.ValueOf(p).CanAddr() unexpectedly returns false.

I'd not say it's unexpected, the docs say:


CanAddr reports whether the value's address can be obtained with Addr.
Such values are called addressable. A value is addressable if it is an
element of a slice, an element of an addressable array, a field of an
addressable struct, or the result of dereferencing a pointer. If
CanAddr returns false, calling Addr will panic.


None of the cases above are met for 'p'.

However, the "dereferencing a pointer" case works as documented:
https://go.dev/play/p/Wn0NdsFNa4g

-- 
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/CAA40n-UEUe%3DPpvBzaPw7ts21U%2BXN6yip__-DwUoOW3SuJ_8qaw%40mail.gmail.com.


Re: [go-nuts] Re: Using go run with #!

2023-06-21 Thread Jan Mercl
On Wed, Jun 21, 2023 at 8:33 PM Dzmitry Lahoda  wrote:
>
> rust just got shebang and cargo in one file. i was hoping using go as good 
> fit for some cases. but seem it will be rust. we are go, bash, nix, rust 
> coders. sure there is some js in our repo. but i hate it. i like to so script 
> which goes into production. bash and nix goes to ops and devs and qa. rust 
> and go go to devs. so with rust now i can at least start and know where it 
> ends. hope go will be sane in that area soon too. go is very good language 
> for one file things so, speed of compilation faster than speed of python or 
> powershell or js whatever garbage they do to setup and run.

See for example https://stackoverflow.com/a/30082862

-- 
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/CAA40n-XV1o5iUaw56NoXBQ7WU1skyMCTWJHw0X37r-TfOPOxdg%40mail.gmail.com.


Re: [go-nuts] Unexpected circular type definition limitation

2023-06-15 Thread Jan Mercl
On Thu, Jun 15, 2023 at 10:16 AM christoph...@gmail.com
 wrote:

> It is possible to define two structures globally with mutual type dependency 
> as this:
>
> type A struct {
> B []B
> }
>
> type B struct {
> A A[]
> }
>
> but I just noticed that we can't do that inside a function:
>
> func Foo() {
> type A struct {
> B []B
> }
>
> type B struct {
>A A[]
> }
> }
>
> Is there a reason for this limitation ?

Syntax error: https://go.dev/play/p/ZOGyZyQDW0I

-- 
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/CAA40n-U_zMgXOrRrMzq%2BxeONRGxHzRB-vW4WWcpXzVq%2BWQoMJA%40mail.gmail.com.


Re: [go-nuts] Hosting to deploy && run exe ?

2023-06-11 Thread Jan Mercl
On Sun, Jun 11, 2023 at 7:40 PM alex-coder  wrote:

> Could you please advise me the simple  hosting to deploy && run a small exe 
> assembled from go.

I'm using https://www.hetzner.com/cloud?country=us and Google Cloud
free tier.  The later natively supports deployment of Go programs.

-- 
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/CAA40n-XpscvL%3DDR-ryi4YN0BafWiXzG_v3ffiYEF%3D1OyDNF2JA%40mail.gmail.com.


Re: [go-nuts] Re: HTTP client timeout

2023-05-05 Thread Jan Mercl
On Fri, May 5, 2023 at 4:21 PM envee  wrote:
>
> Thanks Jan.
> My interface speed is 20 Gb/s
> The payload size is about 2.8Kb.
> So at 9000 Txn/s this works out to 9000 x 3 ≅27MB/s ≅ 200 Mb/s (This matches 
> the so (socket out) value shown in my atop command output)
> I guess the interface speed is sufficient ?

Yes it is.

Next question: what's the speed of the slowest segment en route? ;-)

-- 
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/CAA40n-Xw3bTGhhg0DZem%2BHMg433%2Bm4wvrmNk6AuaGZXasYhwLA%40mail.gmail.com.


Re: [go-nuts] Re: HTTP client timeout

2023-05-05 Thread Jan Mercl
On Fri, May 5, 2023 at 2:45 PM envee  wrote:

> Still, I don't understand why I cannot achieve higher throughput than 9000 
> per second.

What  is the max bitrate of the network interface used in the
measurement and what is the size of the payload that has to get
through for every connection?

-- 
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/CAA40n-Wavm9vJ6WBQ%3DtAgRwiquDgXMaMj%2B17BLT6%3DF32Jh7Tbw%40mail.gmail.com.


Re: [go-nuts] Re: Home directory?

2023-04-23 Thread Jan Mercl
On Sun, Apr 23, 2023 at 10:28 AM Amnon  wrote:

> Yes GOPATH and GOROOT have been deprecated.

Both are alive and well. They are essential for the build system/go
command to work as required.

tl;dr: There's a default value of GOPATH so one does not have to set
it. A much longer version can be obtained by '$ go help gopath'.

-- 
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/CAA40n-V%2BR6o9XNN%3DXwoOt3t6WABe0ch69Pc3%2BV-S8QPW7dGRoQ%40mail.gmail.com.


Re: [go-nuts] gofmt: expected declaration, found ')'

2023-04-16 Thread Jan Mercl
On Sun, Apr 16, 2023 at 12:51 PM Andreas Götz 
wrote:

> Isn't gofmt ist part of the go command? Go ist the latest version:

It is but it's a separate binary/executable file. Go version is one thing,
the version of the binary file that is actually executed when '$ gofmt' is
invoked is another thing, not necessarily related for many possible
reasons, like alias, $PATH etc.

Try to check by issuing something like:

jnml@3900x:~$ go version -m $(which gofmt)
/home/jnml/bin/gofmt: go1.18.5
path cmd/gofmt
jnml@3900x:~$

-- 
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/CAA40n-UTurST8w%2BammqS6-6KGt0JQQych_skWEpyy7rSFmdmAw%40mail.gmail.com.


Re: [go-nuts] gofmt: expected declaration, found ')'

2023-04-16 Thread Jan Mercl
On Sun, Apr 16, 2023 at 12:17 PM Andreas Götz  wrote:
>
> Good morning. Please excuse me for asking here- I'm stuck with something that 
> looks like a gofmt bug though that seems very unlikely.
>
> In CI 
> (https://github.com/evcc-io/evcc/actions/runs/4712710735/jobs/8357929411?pr=7485)
>  I'm using a "porcelain" step to make sure only go-fmt'ed sources are checked 
> in:
>
> gofmt -w -l $(find . -name '*.go')
>
> This step fails with: expected declaration, found ')' on this line which 
> seems lengthy but perfectly valid:
>
> func decorateKeba(base *Keba, meter func() (float64, error), meterEnergy 
> func() (float64, error), phaseCurrents func() (float64, float64, float64, 
> error), phaseVoltages func() (float64, float64, float64, error), 
> phaseSwitcher func(int) error) api.Charger {
> ...
> }
>
> Funny enough, the error happens on CI only. I've recently noticed that Go 
> issues had identified and fixed a mis-compile error and I'm wondering if that 
> (or similar) might be hitting here due to wrong binary code?
>
> Any thoughts?

It's not enough to show the place of error, the preceding context may
cause it. Can you provide the whole file? Your snippet formats just
fine: https://go.dev/play/p/3GqFunldeq0

-- 
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/CAA40n-XdrYSV-jkr%2BWBvz8Gd81uAqgr0%2Bp9dZoycBJppOwz88w%40mail.gmail.com.


Fwd: [go-nuts] Redfining loop variable semantics - what's the plan?

2023-04-11 Thread Jan Mercl
Resending to the mailing list as that was my intention but I errored
again. Did the gmail UI changed again?

-- Forwarded message -
From: Jan Mercl <0xj...@gmail.com>
Date: Tue, Apr 11, 2023 at 9:11 AM
Subject: Re: [go-nuts] Redfining loop variable semantics - what's the plan?
To: Axel Wagner 


On Tue, Apr 11, 2023 at 7:46 AM 'Axel Wagner' via golang-nuts
 wrote:

> You shouldn't *have* to read the language spec to understand what Go code 
> does.

This is the most strange claim I have read about Go ever.

You *must* read the language spec to understand what any programming
language does. You *cannot* just guess because "other languages" do
somethíng or use similar approaches and then be surprised you have
guessed wrong. And as can be seen often, blame the language designers
they didn't meet your unfounded expectations.

What bothers me personally about the proposal and why I think it's a
bad idea: The semantics will be defined by metadata. Any Go code
snippet with such a loop, existing or future, all over the
Internet/books/blogs, ... will become ambiguous in what it does
without those metadata, which are not usually/always available
alongside. You can say "other languages have that problem as well, see
the different C, Perl, Python, you name it... versions". And you would
be right. The point is that the Go 1 compatibility promise gave us the
nice property of Go not suffering from such problems.

I oppose the idea of introducing such a problem into the language
voluntarily, 10+ years later.

Maybe it would be better to bite the bullet, introduce Go 2 and
embrace the shizma. /s

-- 
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/CAA40n-UQaK1dBvo-690Z1VZDZ%2B%2BKL7gQGWi5Mq3G4x4mrxZuyg%40mail.gmail.com.


Re: [go-nuts] Various questions about posts from The Go Blog

2023-03-26 Thread Jan Mercl
The only broken thing in the code below is the TestHello function.
rsc.io/quote uses rsc.io/sampler where the Hello func
(https://pkg.go.dev/rsc.io/sampler#Hello) is documented to return a
localized string by default. Localized, in the sense of respecting the
user's locale. That is not compatible with your test function
expecting to always get the same string regardless of locale. That's a
bug.

On Sun, Mar 26, 2023 at 7:47 PM Kamil Ziemian  wrote:

> According to the law that any change can break your program/workflow, I want 
> to mention that code shown in "Using Go Modules" 
> https://go.dev/blog/using-go-modules is broken in funny way.
>
> Consider code below
> package hello
>
> import "rsc.io/quote"
>
> func Hello() string {
> return quote.Hello()
> }
>
> We also have test file
> package hello
>
> import "testing"
>
> func TestHello(t *testing.T) {
> want := "Hello, world."
> if got := Hello(); got != want {
> t.Errorf("Hello() = %q, want %q", got, want)
> }
> }
>
> So I run `go test' and get
> --- FAIL: TestHello (0.00s)
> hello_test.go:9: Hello() = "Witaj świecie.", want "Hello, world."
> FAIL
> exit status 1
> FAIL example.com/hello 0.002s
>
> What happened? My first language is polish, so my system, Ubuntu 22.04, use 
> it as main language. In some way "rsc.io/quote" figure it out and now 
> function quote.Hello() returns "Witaj świecie.", which in polish mean "Hello, 
> world.". Since we compered result we get with string "Hello, world." we 
> obviously fail the test.
>
> This is just teaching example, so this is not so big deal, but fact that some 
> code of this type is not portable between OS with different languages is a 
> bit disturbing.

-- 
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/CAA40n-UvP9FzMzUyTVzFdKnb%2BHo_zjnonvyUa%3DtchEWu7JV4Ug%40mail.gmail.com.


Re: [go-nuts] How to generalize parameters for a function

2023-03-15 Thread Jan Mercl
On Wed, Mar 15, 2023 at 11:03 AM Frank Jüdes  wrote:
>
> Well, that didn't go very far: https://go.dev/play/p/UtsrRar9J0Q
> Fails with the messages
> ./prog.go:15:11: invalid operation: cannot index p_Map (variable of type MAP 
> constrained by DataMap)
> ./prog.go:16:26: cannot range over p_Map (variable of type MAP constrained by 
> DataMap) (MAP has no core type)

https://go.dev/play/p/6KN36eeomML

-- 
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/CAA40n-WAqUuSR_896rz4C%3DSDOH3LGxZhC4DQ8%2BEVqh%2BM0JKUKw%40mail.gmail.com.


[go-nuts] Building Go 1.21 for openbsd/386

2023-02-22 Thread Jan Mercl
The subject target is not distributed by the Go team. Attempting to build
if from sources in a qemu 4GB VM [OpenBSD 7.2 (GENERIC.MP) #404: Tue Sep 27
12:54:46 MDT 2022] via

$ GOROOT_BOOTSTRAP=~/go1.19 nohup ./make.bash

  produces

Building Go toolchain1 using /home/jnml/go1.19.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
# cmd/compile/internal/ssa
fatal error: runtime: out of memory

runtime stack:
runtime.throw({0x87b8037, 0x16})
/home/jnml/goroot/src/runtime/panic.go:1047 +0x4d fp=0xcf7c860c
sp=0xcf7c85f8 pc=0x80832fd
runtime.sysMapOS(0x89c0, 0x40)
/home/jnml/goroot/src/runtime/mem_bsd.go:71 +0x144 fp=0xcf7c8638
sp=0xcf7c860c pc=0x805d764
runtime.sysMap(0x89c0, 0x40, 0x8d4bc10)
/home/jnml/goroot/src/runtime/mem.go:142 +0x3f fp=0xcf7c8648
sp=0xcf7c8638 pc=0x805d59f
runtime.(*mheap).grow(0x8d3e3e0, 0x9)
/home/jnml/goroot/src/runtime/mheap.go:1459 +0x2b1 fp=0xcf7c869c
sp=0xcf7c8648 pc=0x8073d51
runtime.(*mheap).allocSpan(0x8d3e3e0, 0x9, 0x0, 0x78)
/home/jnml/goroot/src/runtime/mheap.go:1191 +0x2f2 fp=0xcf7c872c
sp=0xcf7c869c pc=0x8073382
runtime.(*mheap).alloc.func1()
/home/jnml/goroot/src/runtime/mheap.go:910 +0x7c fp=0xcf7c8750
sp=0xcf7c872c pc=0x8072cfc
runtime.systemstack()
/home/jnml/goroot/src/runtime/asm_386.s:370 +0x35 fp=0xcf7c8754
sp=0xcf7c8750 pc=0x80b2305

goroutine 4282 [running]:
...

Has anyone successfully built this target from sources and can share how to
build Go 1.21 for openbsd/386?

Thanks in advance.

-j

-- 
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/CAA40n-XXC2D3smiOn%3DJYXLAp7iWiH87zViZuR-K8izgjEY%3DF8Q%40mail.gmail.com.


Re: [go-nuts] CGO Struct used as type parameter causes issue in Go 1.20

2023-02-16 Thread Jan Mercl
On Thu, Feb 16, 2023 at 8:22 AM Jan  wrote:

> Any thoughts ?

A minimal, self-contained and runnable reproducer would be rather
useful in this case.

-- 
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/CAA40n-WDX4vjPunJNBjNspm%2Bj1tdC8cFyO8%3De5xwprsAxaZYGA%40mail.gmail.com.


[go-nuts] SIGSEGV: segmentation violation on Linux/ARM with Microchip SAM9x60 (ARM926 core) processor

2023-02-09 Thread Jan Mercl
A user filled https://gitlab.com/cznic/sqlite/-/issues/132, but I'm not
able to reproduce it on RPi 4 and I don't have access to the subj.
chip/system. It might be possibly something HW related, IDK. Looking for
expert advice for the linux/arm Go target. Anyone out there?

Thanks in advance.

-j

-- 
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/CAA40n-UCwbFz6dt6_GGr2D4vaMmA%3D9hD8dYb%3DnefsHyboA%2BOjA%40mail.gmail.com.


Re: [go-nuts] Drain channel on demand without busy looping?

2023-02-05 Thread Jan Mercl
On Sun, Feb 5, 2023 at 5:12 PM cpu...@gmail.com  wrote:

> Would that still busy-loop? Are there better patterns?

for range q.data {}

iff the sending side properly closes the channel.

-- 
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/CAA40n-VAiRkF7PEZnOq50UnOJf%3D-eptD-hJ9WDaBOC0AvnL1zQ%40mail.gmail.com.


Re: [go-nuts] Re: Context cancellation: Is it sufficient to make long-running things interruptible?

2022-12-20 Thread Jan Mercl
On Tue, Dec 20, 2022 at 9:21 AM Jason E. Aten  wrote:

> Shutting down goroutines quickly was needed so often that I wrote a package 
> to help me with it. it is called idem, short for idempotent.
>
> It uses the idea of an idempotent Close of a channel to signal that the 
> goroutine should stop. This is because Go will panic if
> close a channel more than once (i.e. you wish to stop a goroutine from more 
> than one place).  This is a design flaw in channels,
> but we can work around it by using a mutex.

I disagree with it being a design flaw. Quite the opposite, IMO.
Closing a channel more than once reveals a design flaw in the
respective program and panicking is about the only safe thing to do in
that situation.

Working around this safety feature should be discouraged.

-- 
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/CAA40n-UxSkA6ATXsmXyE9NZtXiOLBFpV8FMRK8y9t829Hu02dQ%40mail.gmail.com.


Re: [go-nuts] Context cancellation: Is it sufficient to make long-running things interruptible?

2022-12-19 Thread Jan Mercl
On Mon, Dec 19, 2022 at 11:01 AM Torsten Bronger
 wrote:

> The context documentation gives this example:
>
> // Stream generates values with DoSomething and sends them to out
> // until DoSomething returns an error or ctx.Done is closed.
> func Stream(ctx context.Context, out chan<- Value) error {
> for {
> v, err := DoSomething(ctx)
> if err != nil {
> return err
> }
> select {
> case <-ctx.Done():
> return ctx.Err()
> case out <- v:
> }
> }
> }
>
> What if the channel “out” is drained very efficiently?  Then, an
> arbitrary number of loop iterations could happen before a
> cancellation is detected, couldn’t it?

>From https://go.dev/ref/spec#Select_statements


2. If one or more of the communications can proceed, a single one that
can proceed is chosen via a uniform pseudo-random selection.


Selecting the send case in the above code, when both cases can
proceed, for N times in a row, should have on average a probability of
2^(-N).

-j

-- 
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/CAA40n-WRAxoBXU9xb3DhmG%3DxcPr0%3DcxdjwX8gq%2B_%3Dwb_OS443A%40mail.gmail.com.


Re: [go-nuts] Tool showing all assignemnts to the blank identifier

2022-11-28 Thread Jan Mercl
On Mon, Nov 28, 2022 at 1:44 PM Wojciech Muła  wrote:

> Is there any tool that would point out places with
> an assignment to the blank identifier?
>
> I'd like to spot possible refactoring/debug leftovers,
> like `_ := func() {}` or unused imports.
>
> I went through the staticcheck list of checks, but
> didn't find anything similar.

$ grep -n '\b_\b :\?= ' *.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/CAA40n-UB%3DWBsK4FJWDDyaZd1q8Ew7iTC%2ByUFwbGXMROOL_0_dg%40mail.gmail.com.


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

2022-11-22 Thread Jan Mercl
Hello Ian,

I have repeatedly asked this user to not use an email address that
spambots back for posting to this list - to no avail, unfortunately. I
think you are the moderator of this ML. I suggest banning posts from
.

Thanks for consideration.

To Robert (not CC'ing you for obvious reasons): You can create an
email for participating on this ML for free in minutes. There are
bazilions of such services available all over the Internet.

-j

-- Forwarded message -
From: 
Date: Tue, Nov 22, 2022 at 4:56 PM
Subject: Re: Re: [go-nuts] clarifying Go FAQ: Is Go an object-oriented language?
To: Jan Mercl <0xj...@gmail.com>


I apologize for this automatic reply to your email.

To control spam, I now allow incoming messages only from senders I
have approved beforehand.

If you would like to be added to my list of approved senders, please
fill out the short request form (see link below). Once I approve you,
I will receive your original message in my inbox. You do not need to
resend your message. I apologize for this one-time inconvenience.

Click the link below to fill out the request:

https://webmail1.earthlink.net/newaddme?a=reng...@ix.netcom.com=11ed-6a7e-3bda9c8e-8843-00144ff8e89f

-- 
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/CAA40n-WXGFH5YVUG5%3DVHf6HE7Z%2BCmB-miqxNqOLhEO%3DNYCf6dA%40mail.gmail.com.


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

2022-11-22 Thread Jan Mercl
On Tue, Nov 22, 2022 at 4:43 PM Robert Engels  wrote:

> Go is not listed as an OO language on Wikipedia.

Check https://en.wikipedia.org/wiki/Go_(programming_language):
"ParadigmMulti-paradigm: concurrent imperative, object-oriented[1][2]"

> Personally I think it is OO-like. OO typically has inheritance.

Typically they may, but that's not the same as what a requirement
would be, right?

> There are also no “class variables” - only package level - which makes some 
> encapsulation patterns harder (every class has to become a package).

No class has to become a package because Go has no classes. You may
think of what a "class" in Go means, but you have not defined that
idea and the language specification is somehow silent about Go
classes.

-- 
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/CAA40n-U%3DG8gqAZEHrnLUxbg5vsAcRkNV35c86c79xcrhSzLSWw%40mail.gmail.com.


Re: [go-nuts] Int64 to []byte and vice-versa

2022-11-21 Thread Jan Mercl
On Mon, Nov 21, 2022 at 9:57 AM Nikhilesh Susarla
 wrote:

> I have an int64 value say 12
> I want to convert that to []byte array.

Such conversion is not supported. Also, []byte is a slice.

However, the desired result can be computed in code. You can use the
encoding/binary package for that. Endianness matters, you cannot avoid
choosing one or another as that selects different results. In some
contexts the right endianness is platform independent, like in many
network/serialization protocols. In some other cases one has to follow
the platform endianness.

HTH.

-- 
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/CAA40n-WOn0gNK3N9Y93-7VictwAtRQuuQZ7bdBbhb8MjngZaGg%40mail.gmail.com.


Re: [go-nuts] Module weirdness in playground

2022-11-18 Thread Jan Mercl
On Fri, Nov 18, 2022 at 7:15 PM Brian Candler  wrote:

> This used to work:
> https://play.golang.org/p/YQoAu1Iwkor
>
> But now when I click on "Run", the import path of "example.com/myprog/foo" is 
> removed, and it fails to compile.
>
> Any clues as to what's going on?

I think the playground uses goimports.

-- 
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/CAA40n-U5S_EPdE9poxBNEQ6T5ESEwHuNf9oiuPuh89Gg%3DRLF%3Dw%40mail.gmail.com.


Re: [go-nuts] Is it possible to switch on type T in a generic function?

2022-11-08 Thread Jan Mercl
On Tue, Nov 8, 2022 at 10:56 AM 'Mark' via golang-nuts
 wrote:
> // Want to sort by T < T //
> elements := make([]string, 0, len(me))
> for element := range me {
> elements = append(elements, fmt.Sprintf("%#v", element))
> }
> sort.Strings(elements)
> /


Not tested:

// Want to sort by T < T //
elements := make([]T, 0, len(me))
for element := range me {
elements = append(elements, element)
}
sort.Slice(elements, func(i, j int) bool { return
less(elements[i], elements[j]) })
/

But you need to extend the less function to handle mixed types. Like
in less(42, "foo").

-- 
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/CAA40n-UC7NevL7EtrLNb9rJRDSXDtf9AaZ-FX497b41XR2jJ5A%40mail.gmail.com.


Re: [go-nuts] Is it possible to switch on type T in a generic function?

2022-11-08 Thread Jan Mercl
On Tue, Nov 8, 2022 at 9:53 AM 'Mark' via golang-nuts
 wrote:

> Given a function:
>
> func F[T comparable](a T) {
> }
>
> is it possible to check T's type inside F?
>
> My use case is that I have a function with signature G[T comparable](x []T) 
> and inside G I want to sort the elements in slice x where T could be int or 
> string.

https://go.dev/play/p/zxQYVvOMX35 ?

-- 
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/CAA40n-Xei-qGr149VjURsfKOp42THVTBowGeFxHY_bdwowYMmQ%40mail.gmail.com.


Re: [go-nuts] Create a 1GB ballast but it takes up RSS and pages are Dirty?

2022-11-06 Thread Jan Mercl
On Sun, Nov 6, 2022 at 12:54 PM Kn (Kn)  wrote:

> Now the problem begins. I expect the ballast like `ballast := make([]byte, 
> 1<<30)` shouldn't take up any physical memory because there's no any writing 
> to it.

The backing array is specified to be zeroed, so we cannot say there's
no writing to it. Depending on the size of the backing array and the
operating system it may not get written as an optimization if backed
by memory the OS can guarantee to be zero filled. Only then it may
remain not yet bound to physical memory.

A simple implementation will just zero it, meaning the opposite
happens - every byte of the backing array gets written and backing
pages for it get allocated.

-- 
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/CAA40n-WhWtgS0ptDw6HNBnFa%3DD1Gq9rT7h%2Bx20iLLF%3Dc5QgnRw%40mail.gmail.com.


Re: [go-nuts] Underscore symbol

2022-11-04 Thread Jan Mercl
On Fri, Nov 4, 2022 at 6:54 PM Canuto  wrote:

> I'm just starting out with go ...
> I have searched for lights on this string but without success.
> What does this sign mean " _, err " , what the underscore symbol means here ?
>
>  func generateSalt() string {
>  randomBytes := make([]byte, 16)
>  _, err := rand.Read(randomBytes)
>   if err != nil {
> return "" }

The language specification is the best place where to look for such
information: https://go.dev/ref/spec#Blank_identifier

-- 
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/CAA40n-WgGJ4uYQ1qG-JDATG06PTWu3D%3DEf-t-PtH_QGOnEr0kQ%40mail.gmail.com.


Re: [go-nuts] godoc and generic code

2022-11-03 Thread Jan Mercl
On Thu, Nov 3, 2022 at 12:49 PM Hotei  wrote:

> I added some generic code to a project and godoc doesn't seem to like that 
> and stops working when it sees the generics.  It's a 4 year old version of 
> godoc so that's perhaps not a surprise.  What is a surprise is that godoc 
> isn't shipped with go any longer.  Is there a version that handles generics 
> and if so where can I find it?  A quick search of github came up empty but I 
> know things have been moved around so some hints would be much appreciated.

I'm not in favor of the fact, but It's been deprecated a year ago:
https://github.com/golang/go/issues/49212

-j

-- 
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/CAA40n-WA7DgrswXk_QrCBYX24au--MTEKbraQFALt-_YHwmC0A%40mail.gmail.com.


Fwd: Re: [go-nuts] There is a passage in book that is difficult to understand, can anyone help explain it?

2022-11-02 Thread Jan Mercl
Please do not post to this _mailing list_ from an email address that
bot-spams my inbox when I reply. I have asked you to fix this at least
one time before.

Perhaps configuring your email to drop anything from my address would
resolve the problem?

-- Forwarded message -
From: 
Date: Wed, Nov 2, 2022 at 6:10 PM
Subject: Re: Re: [go-nuts] There is a passage in book  that is difficult to understand, can anyone help
explain it?
To: Jan Mercl <0xj...@gmail.com>


I apologize for this automatic reply to your email.

To control spam, I now allow incoming messages only from senders I
have approved beforehand.

If you would like to be added to my list of approved senders, please
fill out the short request form (see link below). Once I approve you,
I will receive your original message in my inbox. You do not need to
resend your message. I apologize for this one-time inconvenience.

Click the link below to fill out the request:

https://webmail1.earthlink.net/newaddme?a=reng...@ix.netcom.com=11ed-5ad1-39c53164-82e1-00144ffbff76

-- 
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/CAA40n-VRGGdCJYFQTtb-M80Ukhqr0M2K5foOt-dmS_M%2BwMFsTA%40mail.gmail.com.


Re: [go-nuts] There is a passage in book that is difficult to understand, can anyone help explain it?

2022-11-02 Thread Jan Mercl
On Wed, Nov 2, 2022 at 5:35 PM Robert Engels  wrote:

> I think this can be disproven.
>
> Given a function A with a reentrant lock, it can be rewritten as A with 
> non-reentrant lock and A’ without a lock where A’ is the original A function 
> body.
>
> A’ would then be susceptible to the original “reasoning difficulties” without 
> any locking. I think it shows that any complex function, especially those 
> with recursion, have the same difficulties.

I think up to this point the reasoning is correct - even though it IMO
demonstrates the opposite: If A' handles the invariants incorrectly
then a reentrant lock guarding the A will not help to fix the problem.

IOW, not using a reentrant lock is better because a deadlock/crash is
safer than corrupting data/state.

> Due to sequential consistency, A’ must be correct, since a non-reentrant lock 
> forces a single thread of execution - making A’ and A equivalent.

I think this holds differently: Iff A' is correct then A' and A are
equivalent [in the first approximation ignoring the locking]. So
again, in all cases where the correctness of A' cannot be proven,
avoid "fixing" it by a reentrant lock.

-- 
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/CAA40n-UG%3DpNx7Xkt5UHduS5F5DtiCE1gcK3fL7t-HMjWDtAK1w%40mail.gmail.com.


Re: [go-nuts] How does the go compiler treat initialized string variables?

2022-11-01 Thread Jan Mercl
On Tue, Nov 1, 2022, 20:36 Frank Jüdes  wrote:

> I have to write a program that should verify the content of
> configuration-servers. It will need a lot of pre-initialized data to verify
> the actual content of a server, so it has to initialize many strings. What
> i know from other C-style languages is, that code like
>
> var MyString *string = 'Hello World!';
>
> Will result in having two identical copies of the string »Hello World!« in
> the memory: The first one within the program-code itself and a second copy
> somewhere in the heap-memory.
>

I think the string backing array will be in the text segment as in C. The
string header will end in the data segment, provided it's a package scoped
variable, but the header has no direct equivalent in C.

How will the go-compiler handle something like this:
>
> package main
>   import ("fmt")
>   type MyStruct struct {
> Text string
> Count int32
>   }
>   func main() {
> MyVar := MyStruct{Text: "Hello World!", Count: 20 }
> fmt.Printf("%#v\n",MyVar) }
>
> Will there be two copies of the string »Hello World!" in the memory or
> just one?
>

The backing string  array will exist only once, again in the text segment,
I believe, because there's no reason for making any copies of it in this
case.

>
Not tested/verified

>
>

-- 
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/CAA40n-XoZNA%2Bfu4G2X%2Bar9pJ4RyrEfYsbY2YmgvGeU%2BeUCwDTQ%40mail.gmail.com.


Re: [go-nuts] Integration testing program that internally forks itself

2022-10-27 Thread Jan Mercl
Any recursion that does not have a terminating condition will try to
recurse infinitely ;-)

I'm passing a command line flag in such situations - when testing, but the
best option depends on the particular use. Elsewhere, in a command that
starts a server or talks to the server, I used, for example, an ephemeral
@named socket, which nicely handled both the termination condition and the
communication and is even safe for concurrent processes competing with each
other.

On Thu, Oct 27, 2022, 18:05 Vjeran  wrote:

> We have a program that forks itself in order to do some work
> so calling `./program do` internally finds its path using os.Executable
> and calls `./program do2`
>
> Now when trying to do integration tests program spawns itself and repeats
> test causing an infinite loop?
>
> Any ideas how to handle it?
>
> --
> 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/6f62afc4-af7a-4548-85c5-6514c2e20a49n%40googlegroups.com
> 
> .
>

-- 
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/CAA40n-W%2BfpjUECDrQhbEEzc%2B-F-Zd6M1h11K5UacwJMHSPaPUw%40mail.gmail.com.


Re: [go-nuts] Occasional hard lockup w/ 100% CPU usage in go applications

2022-10-26 Thread Jan Mercl
On Wed, Oct 26, 2022 at 3:28 PM Steven Sokol  wrote:

> Currently running go 1.9.1, but I've been having this same issue since I 
> started working on this project about two years ago on 1.5.x.

That version is 5 years old: https://go.dev/doc/devel/release#go1.9

Can you try a recent, supported version? (Go 1.18+)

-- 
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/CAA40n-XrwHNF_0hua-_6ASG5UdRytLzn431Ra-vt73qodJbgUg%40mail.gmail.com.


Re: [go-nuts] How to add zero after a decimal point in float datatype

2022-10-12 Thread Jan Mercl
On Wed, Oct 12, 2022 at 9:31 PM pravin chaudhary  wrote:

> I need to add zero after a decimal point to a float datatype but not able to 
> do.
>
> Required float value = 5.00 but getting as 5
>
> Datatype should be float only!!
>
> Any help will be much appreciated!

Is this perhaps what you're looking for? https://go.dev/play/p/LnaYYA_8VOg

-- 
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/CAA40n-WV%2BD3QCa6q%3DcUNi338-cZTBkNyUpbODHxVYZL%2BiG2G_A%40mail.gmail.com.


Re: [go-nuts] Zero-sized data type

2022-10-12 Thread Jan Mercl
On Wed, Oct 12, 2022 at 6:01 PM Richiise Nugraha 
wrote:

> Hi, I am looking for zero-sized data type, something like Flexible Array
Member.
> The size of `struct {}` is indeed zero, but for what reason when it's
inside a struct with another member say (https://go.dev/play/p/DpydJIke7dS):
>
> type C struct {
> Pre   uint64
> Inner struct{}
> }
>
> That struct sized for 16, while the sum of all member sizes is only 8,
it's like there's hidden padding/align.

IINM, if the last field of a Go struct has zero size the struct is
extended by at least one byte to prevent taking the address of the
zero sized field that could be outside of the allocated memory area
for the instance of C. (That could, for example, make the precision garbage
collector consider the following memory block reachable when it is not.)

If that's the case then the definition above is actually laid out as

type C struct {
Pre uint64
Inner byte
}

Note that the flexible array member concept of C is in most cases not
compatible with memory managed
by the Go runtime as described in the documentation for package unsafe. It
should be fine in memory
not managed by the Go runtime, though.

-j

-- 
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/CAA40n-WLF1YZuT-cGyZ3JF6hyfUfKFgHiQbvGoHeoK4AuaQ9UA%40mail.gmail.com.


Re: [go-nuts] workspace question

2022-10-12 Thread Jan Mercl
On Wed, Oct 12, 2022 at 4:49 AM Steve Roth  wrote:
>
> I'd appreciate help with setting up a workspace, involving two modules
that exist only on my local disk and not in any SCM.  I understand how to
create the workspace and use both modules in it.  What I can't figure out
is how to add a dependency from mod1 to mod2 in mod1's go.mod file.
>
> The supported means of adding dependencies in go.mod files is the go get
command.  But if I go into mod1's directory and run "go get path/to/mod2",
it tries to download it from github and fails.  I cannot figure out how to
tell go get to use the version that's on my local disk, even though the
workspace says it should.
>
> Similarly, I can't figure out how to add the necessary go.mod and go.sum
entries manually.  The documentation explicitly warns against trying to do
so, anyway.
>
> It seems like this is exactly the case workspaces were designed for,
developing two modules at once, and yet I've had no success in getting it
set up.  Any suggestions?

For example:

jnml@3900x:~/tmp/modules/bar$ rm -rf *
jnml@3900x:~/tmp/modules/bar$ go mod init example.com/bar
go: creating new go.mod: module example.com/bar
jnml@3900x:~/tmp/modules/bar$ echo 'package bar; func Y() {}' > bar.go
jnml@3900x:~/tmp/modules/bar$

and

jnml@3900x:~/tmp/modules/foo$ rm -rf *
jnml@3900x:~/tmp/modules/foo$ go mod init example.com/foo
go: creating new go.mod: module example.com/foo
jnml@3900x:~/tmp/modules/foo$ echo 'package foo; import "example.com/bar";
func X() { bar.Y() }' > foo.go
jnml@3900x:~/tmp/modules/foo$ go build -v
foo.go:1:21: no required module provides package example.com/bar; to add it:
go get example.com/bar
jnml@3900x:~/tmp/modules/foo$ go work init
jnml@3900x:~/tmp/modules/foo$ go work use ../bar
jnml@3900x:~/tmp/modules/foo$ go build -v
directory . is contained in a module that is not one of the workspace
modules listed in go.work. You can add the module to the workspace using go
work use .
jnml@3900x:~/tmp/modules/foo$ go work use .
jnml@3900x:~/tmp/modules/foo$ go build -v
jnml@3900x:~/tmp/modules/foo$

HTH

-j

-- 
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/CAA40n-UP8jVVE81AskP9GKFSd63Gkv7cT2jqDBAkZZ0v-2ENPg%40mail.gmail.com.


Re: [go-nuts] int64(math.Inf(+1)) != math.MaxInt64

2022-10-03 Thread Jan Mercl
On Tue, Oct 4, 2022 at 4:18 AM Jonathan Pearson  wrote:

> I expected int64(math.Inf(+1)) == math.MaxInt64, but it does not.

Quoting from https://go.dev/ref/spec#Conversions, section
"Conversions between numeric types"


In all non-constant conversions involving floating-point or complex
values, if the result type cannot represent the value the conversion
succeeds but the result value is implementation-dependent.


AFAICT, this is working as intended. FTR, also in my experience,
different targets produced different results for the same values the last
time I ran into this issue some years ago.

-- 
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/CAA40n-XCahW0HryaUnzH2Por_R2bwhAzfy0aJckjP9NMFUhFQA%40mail.gmail.com.


Re: [go-nuts] Struggling w/ use of a waitgroup

2022-10-02 Thread Jan Mercl
On Sun, Oct 2, 2022 at 7:36 PM Robert Solomon  wrote:

> https://go.dev/play/p/gIVVLsiTqod

I believe wg.Add on line 125 is too late. I think it needs to be moved
before the go statement on line 108. Not tested.

-- 
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/CAA40n-WBNtF6mi4kG%2BCqJCvFp-MOf3i7Y4%2BRsSmk9SooWyfXxg%40mail.gmail.com.


Re: [go-nuts] Go routine context

2022-10-02 Thread Jan Mercl
On Sun, Oct 2, 2022 at 3:00 PM Robert Engels  wrote:

> They are still non-preemptive. Even the way preemption is implemented is 
> cooperative.

Goroutines are preempted in a thread signal handler that invokes the
Go runtime scheduler that in turn saves the required goroutine state
and switches the execution context to a different goroutine, if
available.

Which part of that do you call "cooperative"?

-- 
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/CAA40n-Vw8YixifiETd2VuAMZyGDfJbr7NeuBtU78BHgPzCxRrQ%40mail.gmail.com.


Re: [go-nuts] Go routine context

2022-10-02 Thread Jan Mercl
On Sun, Oct 2, 2022 at 3:04 PM Robert Engels  wrote:

> One other thing, if you don’t think he knows exactly how Go routines are 
> implemented you are delusional.

Maybe he should then fix the Wikipedia article I linked before. Good
luck with that.

PS: I assume you meant "goroutines" instead of "Go routines".

-- 
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/CAA40n-WXjyeW6uHkWvXJyRKxdSmvgbRObkS_%2BxTENSOCRW770A%40mail.gmail.com.


Re: [go-nuts] Go routine context

2022-10-02 Thread Jan Mercl
On Sun, Oct 2, 2022 at 2:47 PM Robert Engels  wrote:

> I already pointed that out.Go routines were non preemptive until recently. 
> They are also still non preemptive when calling a system call without direct 
> support, or CGo - it spins up another platform thread.

I'm talking about a principal difference that your "god" seems to not
understand. You are pointing out a particular past implementation
deficiency that has nothing to do with the principle.



-- 
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/CAA40n-UnoN4tkSpz%3Dc-1igE3mqpQUbss3HPm7v0MVkt4LAYrWw%40mail.gmail.com.


Re: [go-nuts] Go routine context

2022-10-02 Thread Jan Mercl
On Sun, Oct 2, 2022 at 1:16 PM Robert Engels  wrote:

> By many definitions Go routines and virtual threads are technically 
> coroutines - versus a platform/OS thread.

Show one please.

Coroutines are normally a subject of non-preemptive multitasking,
threads are normally just the opposite. [0]


  [0]: https://en.wikipedia.org/wiki/Coroutine

-- 
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/CAA40n-XF7mF0--NbisAQoUHXEj-F1O_VUgxZ_nf1dJmipZTz3g%40mail.gmail.com.


Re: [go-nuts] Go routine context

2022-10-02 Thread Jan Mercl
On Sun, Oct 2, 2022 at 1:37 AM Robert Engels  wrote:

> I don’t see any arguments refuting the claim? Can you include a link so the 
> analysis can be read in context?

The word "coroutines" does not ring a bell?

-- 
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/CAA40n-VVTEdU0KczveQgqQy%3DaBtoBTVP%2B6yq7gbRR53Vh1HYmA%40mail.gmail.com.


Re: [go-nuts] Re: Question on 'cmd/compile: handle partially overlapping assignments' behavior on ARM64.

2022-09-20 Thread Jan Mercl
On Tue, Sep 20, 2022 at 6:02 PM peterGo  wrote:

> Yes, I read that too. A fundamental tenet of science is reproducibility. I 
> was able to reproduce the AMD64 results and documented it. A step forward.

5:24 PM (45 minutes ago) > I am unable to reproduce your results on AMD64.
6:02 PM (7 minutes ago) > I was able to reproduce the AMD64 results
and documented it.

-- 
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/CAA40n-W3MPpt4ifmgD76kiaMRBHvS-j5ohpcbiYVM3HE_6sA4g%40mail.gmail.com.


Re: [go-nuts] Re: Using golang variable in bash script Command

2022-09-19 Thread Jan Mercl
On Mon, Sep 19, 2022 at 2:52 PM Amnon  wrote:

> What happens if the user enters the string "'; rm -fr ~;'" ?

https://twitter.com/codepo8/status/1373224835866882048

-- 
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/CAA40n-UGc%2BGqd3V1FzePvB745zB1puMoNwoX-UJeJM6wJu_31Q%40mail.gmail.com.


Re: [go-nuts] Using golang variable in bash script Command

2022-09-19 Thread Jan Mercl
On Mon, Sep 19, 2022 at 11:50 AM PK  wrote:

> search:=scanner.Text()
> cmd1,err:=exec.Command("bash", "-c", "find . -name '*$search*'")

Try something like this, not tested:

cmd, err := exec.Command("bash", "-c", fmt.Sprintf("find . -name
%s", search))

-- 
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/CAA40n-Up7L%2B%3D%3DcRSftkwvn7VBWDLmpsJmeY%2B8TVTkfzjnd-JMQ%40mail.gmail.com.


Re: [go-nuts] Race detector question

2022-09-16 Thread Jan Mercl
On Fri, Sep 16, 2022 at 4:42 PM Robert Engels  wrote:

> I don’t know what is happening. The message you just sent came from you not 
> the list. This is not how it is supposed to work. That is why there is a 
> problem.

FYI, I'm posting to the list from the GMail web client. This time I
have manually removed you from the recipients list.

That's all I know, sorry.

-- 
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/CAA40n-XK%2BMuLk5PaVsck3yJe1-gZCu1c6T_odv%2BmF0HeFB7D%3Dw%40mail.gmail.com.


Re: [go-nuts] Race detector question

2022-09-16 Thread Jan Mercl
On Fri, Sep 16, 2022 at 4:23 PM Robert Engels  wrote:

> Normally when people reply to the list it only comes from the list - and the 
> list is allow listed.

All people in this thread sent their replies to both you and the list.

> You are the first person in years to say anything about this. Sorry. I don’t 
> think there is much I can do except change email addresses to one. Y a 
> different provider.

Not that I understand what you mean, but the only thing I want is that
your mailbot stops sending me emails. And no, I don't want to register
my email anywhere to get white listed.

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/CAA40n-WE4jwW8ZisK1Or1s2HEq-mcOeDcwAvTHy%3DmUcKtV849A%40mail.gmail.com.


Fwd: Re: [go-nuts] Race detector question

2022-09-16 Thread Jan Mercl
To reng...@ix.netcom.com:

Please stop your silly bot or use a different email address. You're
using this email to participate in a discussion in a mail group. It's
pretty common to reply to the group and to the OP.

Feel free to send me an off-list message if _you_ think it's
necessary, but avoid a reply bot to spam my inbox, thank you.
Otherwise I propose the admin of this list to ban your email.

-- Forwarded message -
From: 
Date: Fri, Sep 16, 2022 at 9:09 AM
Subject: Re: Re: [go-nuts] Race detector question
To: Jan Mercl <0xj...@gmail.com>


I apologize for this automatic reply to your email.

To control spam, I now allow incoming messages only from senders I
have approved beforehand.

If you would like to be added to my list of approved senders, please
fill out the short request form (see link below). Once I approve you,
I will receive your original message in my inbox. You do not need to
resend your message. I apologize for this one-time inconvenience.

Click the link below to fill out the request:

https://webmail1.earthlink.net/newaddme?a=reng...@ix.netcom.com=11ed-358e-8d00da44-9696-00144ff9a1a5

-- 
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/CAA40n-Wdncw3FsWFDvR5k8noaR5An0aab0qS%2BeQxT05B8Mx3UA%40mail.gmail.com.


Re: [go-nuts] Race detector question

2022-09-16 Thread Jan Mercl
On Fri, Sep 16, 2022 at 7:43 AM robert engels  wrote:

> After some analysis and discussion, the sample I provided earlier has a data 
> race by definition - although in many cases these are benign and do no affect 
> the correctness of the program.

There's no such thing [in Go and many other languages] as a benign
data race: 
https://docs.google.com/document/d/1WAT22FtFdMt43i3O8YrnlQTNTzZ3IoJBtu3P2DNRytg/edit

> E.g. the program may be “sampling” and so any valid value read is “ok”.

Even when we forget that a data race can crash your program on certain
HW, the above quoted means you can replace the read with a PRNG, but
then, assuming your code is still correct, why bother with the read at
all? Because a racy read can produce not only some "old" value vs
"new" value with some probability. The racy read can produce any value
at all. Sure, at least some architectures have stronger guarantees and
they really produce "old" or "new" and nothing else, for certain sizes
and/or alignments of values. But not in the general case or for any
architecture that Go may support in the future.

tl;dr: You must always fix a data race, there are no exceptions.

-- 
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/CAA40n-X5cK9eZpCRAi-yRO9X6s287KF6Dy%3Ds%2BL2%2BqM2CjW2cqQ%40mail.gmail.com.


Re: [go-nuts] Is this a possible bug with pipe

2022-09-14 Thread Jan Mercl
On Thu, Sep 15, 2022 at 1:53 AM ramki...@hotmail.com
 wrote:

> When I submitted it as a bug, this is what I got.  
> https://github.com/golang/go/issues/55029 By chance, do you know what is a  
> buffering for io.Copy?

https://cs.opensource.google/go/go/+/refs/tags/go1.19.1:src/io/io.go;l=385

-- 
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/CAA40n-WWn5sQ8xNP6tKc2WrDKG02Mf24r4bbqZg0mQzmWutixQ%40mail.gmail.com.


Re: [go-nuts] Is this a possible bug with pipe

2022-09-12 Thread Jan Mercl
On Mon, Sep 12, 2022 at 11:16 PM ramki...@hotmail.com
 wrote:
>
> I created a TCP Proxy using io.copy (which creates a splice). Here is the 
> code.
>
> Proxy TCP Server - https://pastebin.com/iAcFjmV1
> Regular TCP Server - https://pastebin.com/V6AN7atV
>
> When using telent to port 8080, the proxy starts and everything typed in the 
> telnet will be returned. After 10 seconds, the connection drop to the proxy 
> but you can see there is one message/packet lost.
>
> Proxy Logs - https://prnt.sc/u76C3KyeXAI3
> Telnet Logs - https://prnt.sc/VK9vbmishxi2
>
> You can see that the proxy ends at the end of when 0 is used in Telnet. 's' 
> is then sent from the Telnet but it's not seen in the proxy.go as shown in 
> the screenshot. 'd' 'f' etc are then seen in the proxy.go.
>
> 's' is lost. Is this a bug?

I think it is - in using io.copy for this job. It's stream oriented
and does not understand packet boundaries. Meaning it can block while
buffering in the middle of a packet, disrupting any handshaking
protocol.

-- 
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/CAA40n-Wgd4UuGWybp6DaWP879EqjJotht5gMry9wwEOwnj42Og%40mail.gmail.com.


Re: [go-nuts] Re: private go documentation server similar to https://pkg.go.dev

2022-09-12 Thread Jan Mercl
On Mon, Sep 12, 2022 at 10:01 AM brainman  wrote:

> I managed to run godoc.
>
> But godoc only displays standard library packages.
>
> Is it possible to configure godoc so it displays packages stored in private 
> github repos ?

I use it with no configuration, '$ GO111MODULE=off godoc -http :6060
&` in particular, and it also shows all packages in $GOPATH. Maybe
setting GOPATH is the configuration you need.

-- 
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/CAA40n-U9VORXvnL1vhKXpMB8y%3DjSYb4Z_hZz0WakTMBofPQ87A%40mail.gmail.com.


  1   2   3   4   5   6   7   8   9   10   >