My own preference is to have a small number of methods and put the general
functionalities into functions. By putting the general functionalities into
functions, you allow code reuse. In object-oriented programming, you
normally attach as many functionalities as possible to their corresponding
On Thu, Mar 17, 2022 at 7:17 PM Zhaoxun Yan wrote:
>
> I just came across this taboo in golang - new methods cannot be added to an
> existing type:
Yes. If we didn't have this prohibition, then the set of interfaces
satisfied by a type would depend on which package was using the type.
See the
Hi there,
Thanks to Go generics in 1.18, I can write a generic function `LenBetween`
for a slice:
```go
func SliceLenBetween[T ~[]E, E any](s T, min, max int) bool {
return len(s) >= min && len(s) <= max
}
```
as well as for a map:
```go
func MapLenBetween[T map[K]V, K comparable, V an
I think it is best to run your code on an encrypted disk. So it cannot be
stolen by taking away the hard-drive.
Furthermore if the config and log files are in other folders, it is okay to
shut down the encrypted drive I guess.
In that case even it is running in memory, the hacker cannot get acces
Hi everyone!
I just came across this taboo in golang - new methods cannot be added to an
existing type:
package main
import "fmt"
func (s string) print(){
fmt.Println(s)
}
func main() {
"hello, world\n".print()
}
--Error
./main.go:5: cannot define new methods on non-local
On Wed, Mar 16, 2022 at 9:44 PM Michael Andersen wrote:
>
> Is there a way to constrain one parameter to be assignable to another?
Currently there is not. We're not sure how to handle that case. See
https://go.googlesource.com/proposal/+/refs/heads/master/design/43651-type-parameters.md#no-way-
On Thu, Mar 17, 2022 at 6:46 AM bbb tt wrote:
>
> I want to encrypt my algorithm library, is there any good way in Go. My
> library is used in both Windows and Linux
For a security issue like this it's essential to define the attack you
want to defend against.
The nature of Go is such that aga
It is my sincere hope that Go will never support anything as poorly
designed as JSON5, using reflection is already slow enough. Comments were
never intended for JSON and never should be added, ever. But since most
discerning development shops are moving to Protobuf for everything that
matters,
>- exotic use-cases are not supported (for example having an integer
*constant* as *generic parameter*, such as you see in C++ fixed size matrix
templates, is not supported)
Does a longer (but not necessarily exhaustive) list of the unsupported
exotic use cases exist? This would be useful to un
Go - FAQ: How do generics in Go compare to generics in other languages?
https://go.dev/doc/faq#generics_comparison
On Wednesday, February 23, 2022 at 9:41:14 PM UTC+1 Jason E. Aten wrote:
> Back in 2009, Russ wrote a blog on generics, talking about the tradeoffs
> in providing generics:
>
>
Thank you very much for this reference. This looks exactly like what I was
looking for. I'm always a fan of getting behind what is out there instead
of making yet another of the thing. I've purchased a copy and so far can
clearly get behind so much of the approach, especially not requiring
anyt
(Just as an aside: please don't post screenshot images. Plaintext is
easier to read and can be copy-pasted. You can also
use https://go.dev/play/ to paste code snippets)
I think you have understood the issue well. From the source code at
https://golang.org/src/runtime/slice.go :
type slice s
I want to encrypt my algorithm library, is there any good way in Go. My
library is used in both Windows and Linux
--
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
t
Go1.18 has a new Mutex TryLock method.
https://pkg.go.dev/sync@go1.18#Mutex.TryLock
Petr
On Wednesday, March 16, 2022 at 9:36:50 PM UTC-4 mumbling...@gmail.com
wrote:
> I'm currently working on a project where I emulate a RISC-V processor for
> the purpose of using Go when teaching concepts
> - is the handler executed in the goroutine of the target?
That's the idea yes.
> But then how does that interact with the goroutine which is already
running? Does it only execute when the goroutine is next blocked in a
select { }, for example? In that case, why not just add a new branch to th
I've tried on a fresh repo without any tags and it worked just fine. Thank
you very much!
On Wednesday, March 16, 2022 at 11:40:39 PM UTC+2 se...@liao.dev wrote:
> It's available if you use the generated pseudoversion as the version in
> the pkgsite url . you can get it via a call to go get (wh
I don't understand the semantics of this. At what point is the handler
function executed and in which goroutine? In other words, when you call `s
:= sig h 1`:
- is the handler executed in the goroutine of the caller? Then how is it
different from `s := h(1)` ?
- is the handler executed in the
thx for this link.
But it implies a specific usage of tags (interpreting them as a "version" /
"pseudo version"). I was thinking about a more general approach, just embed
tags. I added a comment to the github issue.
Then people can check for a tag in buildinfo and eventually use it as
Version
18 matches
Mail list logo