Hi,
I have an io.Reader whose content is encoded in base64 with encoding type
unknown. Since there shouldn't be any ambiguity between the two, is it
possible to make the base64 automatically pick the right one to decode?
Currently I have to read everything out to pin down the encoding, which
d
ee that it might be useful to have some of this functionality
> available in the standard library.
>
> cheers,
> rog.
>
> On Tue, 2 Feb 2021 at 09:08, hey...@gmail.com wrote:
>
>> Hi,
>>
>> I have an io.Reader whose content is encoded in base64 with
ther (and padding can be viewed as
>>>> optional during decoding anyway).
>>>>
>>>> On Tue, Feb 2, 2021 at 2:37 PM Robert Engels
>>>> wrote:
>>>>
>>>>> Base64 is always ASCII. The encoded data may be in an arbitrary
>>>
Hi,
I'm trying to write a Tun device for linux. I learned a lot
from github.com/songgao/water and wireguard-go on how to create a tun
interface.
However, I'm not sure how to leverage std/net to read from and write to it.
water seems to leave the read & write part to its users, and wireguard-go
I'm writing a command line program in go, and it needs to access some
predefined external files like /usr/lib/name/file. What would be a good way
to allow specify the constant path in compile time?
I see two options:
1. go generate
2. -ldflags="-X 'main.Path=..."
Both seem to be flawed. For #1
@Nick @Brian
Somehow I missed your replies.
Using a Makefile makes sense.
And thanks for bringing embed to my attention. I never knew it exists.
Sounds like it can solve my problem.
Thanks a lot.
On Thursday, December 1, 2022 at 6:32:58 PM UTC+8 Nick wrote:
> On Thu, Dec 01, 2022 at 06:21:37P
Hi,
I have this very simple sorting code:
s := make([]int, 0, 100)
for i := 1; i <= 20; i++ {
s = append(s, i)
}
sort.Slice(s, func(i, j int) bool { return i > j })
log.Print(s)
I expect it to print numbers in reverse order, since items with larger
index numbers should be at the front. Howe
, which
> also has a sort
> On Tuesday, December 6, 2022 at 6:39:29 PM UTC-8 hey...@gmail.com wrote:
>
>> Hi,
>>
>> I have this very simple sorting code:
>>
>> s := make([]int, 0, 100)
>> for i := 1; i <= 20; i++ {
>> s = append(s, i)
>
t;
> On Tue, Dec 6, 2022 at 6:45 PM Andrew Harris wrote:
>
>> Subtly:
>> return s[i] > s[j]
>>
>> Is the right sort func
>>
>> I think it'd be recommended to look at the generics slices package, which
>> also has a sort
>> O
t; func reverse[T any](s *[]T) {
> z := len(*s)
> for a := 0; a < len(*s)/2; a++ {
> (*s)[a], (*s)[z-a-1] = (*s)[z-a-1], (*s)[a]
> }
> }
>
> On Tuesday, December 6, 2022 at 6:54:38 PM UTC-8 hey...@gmail.com wrote:
>
>> Thanks for the quick reply.
>>
, we could do:
>> sort.Slice(s, func(i, j int) bool { log.Println(i, j); return i > j })
>>
>> The appearances of i and j per step recapitulate the logic of the sorting
>> algo in some weak sense; not slice order
>> On Tuesday, December 6, 2022 at 7:28:39 PM UTC-8 hey
wrote:
> On Sun, Nov 3, 2024 at 12:41 AM hey...@gmail.com wrote:
> >
> > Not sure generic type alias is the solution, but what I'm trying to do
> is I have a type like this
> >
> > type Map[K comparable, V any] struct { m map[K]V }
> >
> > and I want it t
Not sure generic type alias is the solution, but what I'm trying to do is I
have a type like this
type Map[K comparable, V any] struct { m map[K]V }
and I want it to implement json.Unmarshaller to decode json objects, when
K's underlying type is string:
type omap[K ~string, V any] = Map[K, V]
13 matches
Mail list logo