I don't prefer either. I decide on a case-by-case basis. I generally ignore
the question of scope, though. The relevant question (to me) is
readability. If the statement is short, I use the one-line version,
otherwise (or if I need to use either result after the conditional) I use
the version with
Please ask an actual question, don't just post some code.
FTR the code you posted (with the substitution you suggest) compiles and
runs fine using gotip.
On Fri, Nov 12, 2021 at 6:18 AM tapi...@gmail.com
wrote:
> sorry, a mistake, "int" -> "[]byte".
>
> On Friday, November 12, 2021 at 1:08:50 PM
sorry, a mistake, "int" -> "[]byte".
On Friday, November 12, 2021 at 1:08:50 PM UTC+8 tapi...@gmail.com wrote:
>
> package main
>
> import (
> "fmt"
> )
>
> type byteview interface{string | int}
>
> type ByteView[T byteview] struct {v [0]T}
>
> func (bv ByteView[T]) Write(v T) (int, error) {
package main
import (
"fmt"
)
type byteview interface{string | int}
type ByteView[T byteview] struct {v [0]T}
func (bv ByteView[T]) Write(v T) (int, error) {
return 0, nil
}
type Writer[T byteview] interface {
Write(bs T)(int, error)
}
type ioWriter = Writer[[]byte] // []byte doe
Hi, guys, I want to know which error handling pattern do you prefer.
Following is a code snippet from go stdlib.
https://sourcegraph.com/github.com/golang/go/-/blob/src/net/http/h2_bundle.go?L1848
Let me simplify my questions:
Pattern1: like the code in go stdlib, in the same function, we first
The two instructions are :
MOVD$"".bar.func1·f(SB), R0
and
MOVD$"".bar.func1(SB), R0
--
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.