[go-nuts] Re: Help ASCII armor PGP Messages with golang.org/x/crypto/openpgp

2021-02-28 Thread Hugo3
https://play.golang.org/p/XhnDZwJYdLp On Sunday, February 28, 2021 at 10:57:21 PM UTC-5 Hugo3 wrote: > I used 2 test keys using the key block for Alice as the public key and > Roger as the private key. but receiving a panic error: panic: runtime > error: invalid memory address or nil pointer

[go-nuts] Re: Help ASCII armor PGP Messages with golang.org/x/crypto/openpgp

2021-02-28 Thread Hugo3
I used 2 test keys using the key block for Alice as the public key and Roger as the private key. but receiving a panic error: panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x128 pc=0x51fdd7] On Sunday, February 28,

Re: [go-nuts] Contrary to popular opinion...

2021-02-28 Thread Robert Engels
I wasn’t referring to the mixed tab/space issue. I mean you copy a few live that are at one indentation to another location with a different indentation - everything is mucked up usually. You don’t have these issues with brackets - the code is easily formatted correctly or a bracket added then

Re: [go-nuts] Contrary to popular opinion...

2021-02-28 Thread Justin Israel
On Monday, March 1, 2021 at 9:36:57 AM UTC+13 ren...@ix.netcom.com wrote: > I think the only time the indentation is a problem is when refactoring > code - copying pasting code blocks seems to be a guessing game with my IDEs > and often require manual fixes - the issue seems far less common

Re: [go-nuts] Contrary to popular opinion...

2021-02-28 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2021-02-28 at 10:11 -0800, Bob Alexander wrote: > I never have understood the *serious* hatred of Python's "indentation > as syntax" approach. I've used lots of bracketed and begin/end > languages (C/C++, Algol & relatives, Ruby, and most other programming > languages), and when I write

Re: [go-nuts] Contrary to popular opinion...

2021-02-28 Thread Robert Engels
I think the only time the indentation is a problem is when refactoring code - copying pasting code blocks seems to be a guessing game with my IDEs and often require manual fixes - the issue seems far less common (and more easily corrected) when using brackets. > On Feb 28, 2021, at 12:12 PM,

Re: [go-nuts] Are the two unsafe uses safe?

2021-02-28 Thread Ian Lance Taylor
On Sun, Feb 28, 2021 at 7:52 AM tapi...@gmail.com wrote: > > On Sunday, February 28, 2021 at 8:29:51 AM UTC-5 Ian Lance Taylor wrote: >> >> On Sat, Feb 27, 2021 at 8:00 PM tapi...@gmail.com wrote: >> >> > 2. >> > >> > func String2ByteSlice(s string) []byte { >> > return

Re: [go-nuts] Need help/tips on golang compiler souce code reading

2021-02-28 Thread Ian Lance Taylor
On Sun, Feb 28, 2021 at 7:04 AM zhz shi wrote: > > According Russ's plan(replacing cmd/compile/internal/types with types2) and > the discussion topic Jeremy Faller posted, can I understand it as that check2 > will be the entry of new and default typechecker in the future(with the > release of

Re: [go-nuts] Contrary to popular opinion...

2021-02-28 Thread Bob Alexander
I never have understood the *serious* hatred of Python's "indentation as syntax" approach. I've used lots of bracketed and begin/end languages (C/C++, Algol & relatives, Ruby, and most other programming languages), and when I write code in those languages I usually indent as I write. Obviously,

Re: [go-nuts] Contrary to popular opinion...

2021-02-28 Thread Robert Engels
Popularity has nothing to do with good - thus Twitter and the Kardashians. . > On Feb 28, 2021, at 2:35 AM, 'Dan Kortschak' via golang-nuts > wrote: > > On Sun, 2021-02-28 at 09:23 +0100, Jan Mercl wrote: >> I meant, for example, in regexp notation, ` *` vs `\n *` between a >> function

Re: [go-nuts] Methods and pointer type receivers

2021-02-28 Thread Howard Waterfall
Thanks Brian. It sounds like golang made it illegal to define methods on a defined pointer type for readability/disambiguation reasons rather than some fundamental, underlying technical issue. Frankly the confusion it eliminates still isn’t entirely clear to me. Given that names in general don’t

Re: [go-nuts] Are the two unsafe uses safe?

2021-02-28 Thread tapi...@gmail.com
On Sunday, February 28, 2021 at 8:29:51 AM UTC-5 Ian Lance Taylor wrote: > On Sat, Feb 27, 2021 at 8:00 PM tapi...@gmail.com > wrote: > > > > 1. > > > > func String2ByteSlice(s string) []byte { > > return (*[^uint(0) >> 1]byte)(unsafe.Pointer())[:len(s):len(s)] > > } > > This doesn't

Re: [go-nuts] Re: Resolving type ambiguity w/ functions that return an interface

2021-02-28 Thread Howard Waterfall
Thanks Brian, Axel & Ian for your very thorough treatment of my post. When I first read about golang interfaces, I was impressed with how elegant and powerful they are, so it's very disappointing that my first opportunity at leveraging them was such a fail! Your explanations did a remarkable job

Re: [go-nuts] Need help/tips on golang compiler souce code reading

2021-02-28 Thread zhz shi
That's very helpful, thank you Ian. According Russ's plan(replacing cmd/compile/internal/types with types2) and the discussion topic Jeremy Faller posted, can I understand it as that check2

Re: [go-nuts] Golang Problems

2021-02-28 Thread Jesper Louis Andersen
You've stated the assignment. What have you tried in order to solve it? The best way to get at this is to just jump out in it and start trying stuff and see when it fails. Don't be afraid of stuff falling apart in the beginning. That's not what you are going to hand in, anyway. In addition, we

Re: [go-nuts] Are the two unsafe uses safe?

2021-02-28 Thread Ian Lance Taylor
On Sat, Feb 27, 2021 at 8:00 PM tapi...@gmail.com wrote: > > 1. > > func String2ByteSlice(s string) []byte { > return (*[^uint(0) >> 1]byte)(unsafe.Pointer())[:len(s):len(s)] > } This doesn't do what you probably want, as is not the address of the bytes in the string. > 2. > > func

Re: [go-nuts] golang.org/x/sys and unsafe usage

2021-02-28 Thread Ian Lance Taylor
On Sun, Feb 28, 2021 at 1:06 AM Reto wrote: > > On Sat, Feb 27, 2021 at 06:56:04PM -0800, Ian Lance Taylor wrote: > > Although rule 4 in the documentation of the unsafe package mentions > > syscall.Syscall, the implementation isn't restricted to the syscall > > package. It applies to any

[go-nuts] Re: Resolving type ambiguity w/ functions that return an interface

2021-02-28 Thread Brian Candler
On Sunday, 28 February 2021 at 10:36:55 UTC Brian Candler wrote: > On Sunday, 28 February 2021 at 03:03:17 UTC Deiter wrote: > >> The example uses a “short assignment” statement, so it’s not obvious what >> “concrete” type c.StdoutPipe() returns >> > > You can't tell > By which I meant "you

[go-nuts] Re: Resolving type ambiguity w/ functions that return an interface

2021-02-28 Thread Brian Candler
On Sunday, 28 February 2021 at 03:03:17 UTC Deiter wrote: > The example uses a “short assignment” statement, so it’s not obvious what > “concrete” type c.StdoutPipe() returns > You can't tell, and indeed it might not return any concrete type at all (it may return nil). Given stdout, err :=

[go-nuts] Tool go-offline-packager

2021-02-28 Thread snmed
Hi all If anyone is interested, i made a little tool to download and package go modules for air-gapped environments. Here the link to the repo: https://github.com/go-sharp/go-offline-packager Any comments or suggestions are most welcome. Cheers, Sandro -- You received this message because

Re: [go-nuts] Re: Are the two unsafe uses safe?

2021-02-28 Thread 'Axel Wagner' via golang-nuts
On Sun, Feb 28, 2021 at 9:09 AM tapi...@gmail.com wrote: > Is this error essential? > Yes. You need to be able to do arithmetic on addresses to use an array, but for that they need to have a known type and size. By exceeding the address space, you are creating a type that the compiler can't

Re: [go-nuts] Resolving type ambiguity w/ functions that return an interface

2021-02-28 Thread 'Axel Wagner' via golang-nuts
On Sun, Feb 28, 2021 at 4:03 AM Deiter wrote: > My (clearly flawed) interpretation of interface types suggested that I > could assign the first result from c.StdoutPipe() to anything that > implements io.ReadCloser. > To try and explain the flaw in the argument: These two statements are

Re: [go-nuts] golang.org/x/sys and unsafe usage

2021-02-28 Thread Reto
Thanks to both of you. On Sat, Feb 27, 2021 at 06:56:04PM -0800, Ian Lance Taylor wrote: > Although rule 4 in the documentation of the unsafe package mentions > syscall.Syscall, the implementation isn't restricted to the syscall > package. It applies to any function that is written in assembly:

[go-nuts] Re: Help ASCII armor PGP Messages with golang.org/x/crypto/openpgp

2021-02-28 Thread Brian Candler
Your program does that already, so I'm not sure what the problem is. Note that you don't need the private key to encode. Your function encryptMessage() makes no use of the arguments privateKey, privateKeyPassword - you can simply remove them. https://play.golang.org/p/EbuCRR32C7d Now it's

Re: [go-nuts] Contrary to popular opinion...

2021-02-28 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2021-02-28 at 09:23 +0100, Jan Mercl wrote: > I meant, for example, in regexp notation, ` *` vs `\n *` between a > function signature and the opening brace of the function body. Ah, yes. > This assumes newline is a whitespace. Most programming languages > agree, but humans may not. With

Re: [go-nuts] Contrary to popular opinion...

2021-02-28 Thread Jan Mercl
On Sun, Feb 28, 2021 at 9:05 AM 'Dan Kortschak' via golang-nuts wrote: > I'm curious where the meaningful whitespace is in Go (for amounts > differences in number greater than 1). I meant, for example, in regexp notation, ` *` vs `\n *` between a function signature and the opening brace of the

Re: [go-nuts] Contrary to popular opinion...

2021-02-28 Thread Arnaud Delobelle
E.g. compare a = 1 b = 2 And a = 1 b = 2 They do no mean the same in Go. Arnaud On Sun, 28 Feb 2021, 08:05 'Dan Kortschak' via golang-nuts, < golang-nuts@googlegroups.com> wrote: > On Sun, 2021-02-28 at 08:40 +0100, Jan Mercl wrote: > > Actually Go has that problem as well, just

[go-nuts] Re: Are the two unsafe uses safe?

2021-02-28 Thread tapi...@gmail.com
Sorry, the first one will get a "type [9223372036854775807]byte larger than address space" error. The following code will get the same error var x *[^uint(0) >> 1]byte Is this error essential? On Saturday, February 27, 2021 at 11:00:26 PM UTC-5 tapi...@gmail.com wrote: > 1. > > func

Re: [go-nuts] Contrary to popular opinion...

2021-02-28 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2021-02-28 at 08:40 +0100, Jan Mercl wrote: > Actually Go has that problem as well, just a thousand times smaller. I'm curious where the meaningful whitespace is in Go (for amounts differences in number greater than 1). > FTR, I also think Python's approach to white space is a failure.