Re: [go-nuts] Need help to close/shutdown http server when underlying socket fd explicitly bind used

2024-02-19 Thread Reto
On Sat, Feb 17, 2024 at 10:23:40AM -0800, binbinschen00 wrote:
> If I want to bind the socket fd to another interface for the same http 
> server (meaning same address:port), do I need to close/shutdown the 
> existing server first and start a new one? Is there a way to just modify 
> the socket bind without close/shutdown the socket?

Turns out you can apparently do it post bind, just played around with it.
Question is, should you? It smells like an XY problem to me.
What are you actually trying to do?

But sure, just use the same pattern with the syscall con in whatever logic
you use to switch.
`listener.(*net.TCPListener).SyscallConn()` will give you the interface
needed to do 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/cjtttlaqz24bcv5s4iigwsx4snt2l3sarp5f672yngw2e65kn5%40z4s3ddyj3mu5.


Re: [go-nuts] Need help to close/shutdown http server when underlying socket fd explicitly bind used

2024-02-16 Thread Reto
On Thu, Feb 15, 2024 at 11:30:53AM -0800, Bing wrote:
> I'm trying to implement a http server and I need to bind the underlying 
> socket to a specific VRF instance so that the server only listens on that 
> VRF instance. When some specific event happens, the program needs to 
> shutdown the http server. I'm using syscall.SetsockoptString() and option 
> "SO_BINDTODEVICE".

Pretty sure what you are doing doesn't make sense... aren't you hooking into
the wrong timing?

You need to set the socket option prior to binding, not after.
There's a more convenient interface with a syscall.RawConn than what you are
using.
The attached mod seems to work, maybe try that?

Cheers,
Reto

-- 
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/h36frmpo4ecm337q7zphdqyr4aydg6fdn642gl4fpigoychuwf%40kewug6kxb2li.
package main

import (
"context"
"errors"
"fmt"
"net"
"net/http"
"syscall"
"time"
)

func main() {
// Generate a self-signed certificate and private key
// Create a TCP listener
listenConf := net.ListenConfig{
Control: func(_ string, _ string, c syscall.RawConn) error {
var err error
cerr := c.Control(func(fd uintptr) {
err = syscall.SetsockoptString(int(fd), 
syscall.SOL_SOCKET, syscall.SO_BINDTODEVICE, "eth0")
})
return errors.Join(cerr, err)
},
}
listener, err := listenConf.Listen(context.Background(), "tcp", 
"localhost:443")
if err != nil {
fmt.Println("Error creating listener:", err)
return
}
// Create an HTTP server with the custom listener and TLS config
server := {
Addr:"localhost:443",
Handler: http.HandlerFunc(handler),
}

// Start the HTTP server
go func() {
fmt.Println("Starting HTTP server with TLS...")
if err := server.Serve(listener); err != nil && err != 
http.ErrServerClosed {
fmt.Println("Error starting server:", err)
return
}
}()

// Start a timer
duration := 1 * time.Second
fmt.Printf("Timer started. Server will be closed after %s.\n", duration)
timer := time.NewTimer(duration)

// Wait for the timer to expire
<-timer.C

// Close the HTTP server gracefully
fmt.Println("Closing HTTP server...")
if err := server.Close(); err != nil {
fmt.Println("Error closing server:", err)
return
}

fmt.Println("HTTP server closed.")
}

// Handler for incoming requests
func handler(w http.ResponseWriter, _ *http.Request) {
fmt.Fprintf(w, "Hello, HTTPS!")
}


Re: [go-nuts] wtf

2023-08-27 Thread Reto
On Sat, Aug 26, 2023 at 07:56:30AM -0700, Aln Kapa wrote:
> Need some help, what am I doing wrong?

You don't understand how defer works would be my guess

> func main() {
> Handle(true)// error
> Handle(false)   // no error
> HandleWTF(true) // no error ?

Why do you expect this to print an error?
The deferred call's arguments are evaluated immediately, but the function call 
is not executed until the surrounding function returns.

At the time it is evaluated, err is nil

-- 
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/chscpzfrzxtstele4rmh2lzt37n2xb2dcrltpopcj4c233goo7%40jq4ervvogvmp.


Re: [go-nuts] Packages vs methods

2023-04-04 Thread Reto
On Mon, Apr 03, 2023 at 10:19:49PM -0700, joseph.p...@gmail.com wrote:
> Is there an easy way to make 
> this determination?

Sure, use syntax highlighting in your favor.

-- 
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/mhisvutsz54nkickwqcxw4n2gqn3ccexnidng5i3p43qusxrkh%40tkbismvv64hz.


Re: [go-nuts] GO API to upload a directory in the github

2022-09-28 Thread Reto
On Tue, Sep 27, 2022 at 09:46:04PM -0700, PK wrote:
> I want to write an go script, to upload a folder in the github. Can anyone 
> please let How I can do this.

Depending on what you mean by "upload folder" you can either use git,
assuming you meant source code / version tracked stuff or you can
interact with the GH API either via rest or grahpql.

There's a bunch of info available, say

* https://docs.github.com/en/developers/overview/about-githubs-apis
* https://github.com/shurcooL/githubv4

Go from there.


Cheers,
Reto

-- 
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/20220928052559.wxviviak3yxkmhbs%40feather.


Re: [go-nuts] Whats wrong with my builder pattern

2021-12-05 Thread Reto
Hi,

https://go.dev/doc/faq#methods_on_values_or_pointers

>First, and most important, does the method need to modify the receiver? If it 
>does, the receiver must be a pointer. (Slices and maps act as references, so 
>their story is a little more subtle, but for instance to change the length of 
>a slice in a method the receiver must still be a pointer.) In the examples 
>above, if pointerMethod modifies the fields of s, the caller will see those 
>changes, but valueMethod is called with a copy of the caller's argument 
>(that's the definition of passing a value), so changes it makes will be 
>invisible to the caller.

You have a non pointer receiver, you modify a copy.

Cheers,
Reto

-- 
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/20211206070034.eax4ndyyquydewru%40feather.


Re: [go-nuts] Makefiles for Go Programs

2021-08-23 Thread Reto
On Mon, Aug 23, 2021 at 06:12:43PM -0700, Michael Ellis wrote:
> Three cheers for mage .  It's more verbose than make 
> but it's pure Go. I use it to build and test projects that include 
> generated html/css/js supported by a Web Assembly clients communicating 
> with a server.

It may be nicer, however the beauty of make is that it is ubiquitous,
everybody already has it.

With mage, your installation instructions now need to contain how /
where to get mage in the first place, leaving the user with a random
binary somewhere which they probably never ever need nor update again.

-- 
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/20210824055435.eg46zvnazct7m7dh%40feather.


Re: [go-nuts] Re: How to manage replace directives in go.mod files when code versioning ?

2021-04-27 Thread Reto
On Mon, Apr 26, 2021 at 11:59:47PM -0700, christoph...@gmail.com wrote:
> Thank you for pointing this out. I wasn’t aware of it. But the question
> still holds for published main programs.

If you have such a tight dependency that you need to develop them in parallel
(and hence need replace directives to a local fork) maybe they ought to life
in the same module?
Then you don't need to have a replace directive in the first place.

Other than that, git is your friend... *Do* commit the change and then rebase
the thing away when you don't need it anymore.

-- 
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/20210427142415.4gdlpfcvstn5axgh%40feather.localdomain.


Re: [go-nuts] Go 1.16 and modules

2021-03-28 Thread Reto
On Mon, Mar 29, 2021 at 11:18:28AM +1100, Amit Saha wrote:
> "Module-aware mode is enabled by default, regardless of whether a
> go.mod file is present in the current working directory or a parent
> directory. More precisely, the GO111MODULE environment variable now
> defaults to on. To switch to the previous behavior, set GO111MODULE to
> auto. "
> Is that implying the above behavior?

Yes: https://golang.org/ref/mod#mod-commands

Note that you can still run the hello world programs via `go run` without
having a module.

-- 
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/20210329011453.3dddpz3syc6wv636%40feather.localdomain.


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: that
> is, a function that is declared in Go without a body.
> We should perhaps tweak the docs to make that the rule.

I see, I was assuming that the assembly function of syscall.Syscall does some
(even darker) dark magic than normal assembly to guarantee that.
So a doc update would indeed be helpful.

> Now that you point this out, I'm actually not sure that this is OK.  I
> don't know what keeps v pinned during this call.

> >> IoctlSetPointerInt clearly converts a unsafe.Pointer to a uintptr and 
> >> *doesn't*
> >> directly call syscall.Syscall.
> >>
> >> Why is this valid?

> I'm not sure it is.

Hm, do you want me to open up a bug on GitHub?

The reason I originally asked is that I have a third party module that does
just the same and while writing the patch to actually adhere to the unsafe
constraints, I started reading the stdlib and it's kinda hard to argue for a
patch upstream if the go stdlib uses the exact same pattern ;)

Greetings,
Reto

-- 
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/20210228090612.xfjvyv35qvyukruk%40feather.localdomain.


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

2021-02-27 Thread Reto
Hi,
I'm a bit confused as to how the golang.org/x/sys package works.

>From the documentation of unsafe.Pointer:
>(4) Conversion of a Pointer to a uintptr when calling syscall.Syscall.

> The Syscall functions in package syscall pass their uintptr arguments
> directly to the operating system, which then may, depending on the details
> of the call, reinterpret some of them as pointers.
> That is, the system call implementation is implicitly converting certain
> arguments back from uintptr to pointer.

> If a pointer argument must be converted to uintptr for use as an argument,
> that conversion must appear in the call expression itself

Now, as far as I can tell this forces non stdlib packages to adhere to exactly 
that.
As far as I can tell x/sys is just a common namespace for the go authors, but
as far as the compiler itself is concerned, that's a normal module not the 
stdlib.

Or is this a wrong assumption?

Reason I ask is because the code in x/sys clearly violates that rule.

in unix/ioctl.go there's

```
// IoctlSetPointerInt performs an ioctl operation which sets an
// integer value on fd, using the specified request number. The ioctl
// argument is called with a pointer to the integer value, rather than
// passing the integer value directly.
func IoctlSetPointerInt(fd int, req uint, value int) error {
v := int32(value)
return ioctl(fd, req, uintptr(unsafe.Pointer()))
}
```

and the declaration of ioctl in zsyskall_linux.go:

```
func ioctl(fd int, req uint, arg uintptr) (err error) {
_, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
```

Now, for starters ioctl includes a pointless conversion of a uintptr to a 
uintptr,
for the arg parameter can anyone tell me why?

Second (and this is my actual question), isn't that in violation of the unsafe
constraints cited above?

IoctlSetPointerInt clearly converts a unsafe.Pointer to a uintptr and *doesn't*
directly call syscall.Syscall.

Why is this valid?

Thanks in advance.

Regards,
Reto

-- 
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/20210227221836.kgkn4xskg4xe7gsk%40feather.localdomain.


Re: [go-nuts] sql string not interpolated as expected

2021-01-03 Thread Reto
On Sun, Jan 03, 2021 at 12:53:03AM -0800, Alexander Mills wrote:
> rows, err := c.Database.Db.Query(`
>
> select *, (
> select count(*) from mbk_file_label
> where file_id = mbk_file.id and label_id IN (
> select id
> from mbk_user_label
> where label_name IN (
> $2
> )
> )
> ) as xxx
> from mbk_file
> where user_id = $1
> order by xxx DESC
> `,
> loggedInUserId,
> labelStr,
> )
>
>
> then the query doesnt work and I dont know why?

You might want to debug log your statements in the database engine...
What you want to do is not what it's doing.

You ask the sql engine to escape the input you give it.

So your question becomes `where label_name in ('"carnivore", "mammal", 
"vertebrate"')`
Meaning the string exactly as given as single element.

Maybe that helps: https://stackoverflow.com/a/38878826/6212932 if you use 
postgres.

Cheers,
Reto

-- 
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/20210103092831.l2wlvdshifdzsce3%40feather.localdomain.


Re: [go-nuts] Re: Generics - please provide real life problems

2020-12-25 Thread Reto
You are repeatedly starting new threads, keeping the same subject as already 
existing ones.
Don't do that please, if you respond to a certain topic keep the thread intact.

That way all the conversation is in a single place.

-- 
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/20201225130054.wlctldlfxjf3hmuv%40feather.localdomain.


Re: [go-nuts] can "Run" in play.golang.org automatically include imports and format?

2020-05-30 Thread Reto
On Sat, May 30, 2020 at 01:13:16AM -0700, Sathish VJ wrote:
> Is there a reason why play.golang.org needs separate buttons for Run,
> Format, and Imports?  Is there any reason for or anybody not doing those
> automatically?

Say someone has issues with their code and pastes it to play.golang.org.
You want hitting "run" to say "no module named blah" and not automatically fix 
the
error for them That would be very confusing.

> Shouldn't Run automatically subsume Format and Imports?

No, it should simply run the code in my opinion, after all that's what "run" 
means

> Also, it would be good to have a keyboard shortcut to run it.  It's not
> convenient to shift to a mouse/trackpad.

There is on my computer :P install something like vimperator or use quotebrowser
or some 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/20200530082538.niyttpn3vyrfr6o6%40feather.localdomain.


Re: [go-nuts] Store function name as JSON?

2020-04-29 Thread Reto
On Wed, Apr 29, 2020 at 02:17:44PM -0700, MichaelB wrote:
> I'm trying to store a data point as a JSON (w/struct) with a Call back
> function to call when the item is loaded with data

Functions aren't serializeable to json, it's not one of the types json supports.

> Just marshaling the struct into JSON nets a blank item.. any suggestions?

> type Item struct {
>  name string
>  callback func()
>  data int
> }

If you json.Unmarshal into the above struct it can't work.
json is an external package and hence can only work with exported symbols.
You need to capitalize your struct fields in other words.

> after striking out I thought about switching it to a string and doing a
> switch.. but let me know maybe i'm just doing something wrong with the
> callback definition
Yes, enter a string and switch on that.

Greetings,
Reto

-- 
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/20200430045724.sw44mlpsgac3p7jb%40feather.localdomain.


Re: [go-nuts] Re: Windows syscall.Open() change to fix os.Rename() & .Remove()

2019-08-04 Thread Reto


>They did:
>https://github.com/golang/go/issues/32088#issuecomment-502850674

No, that's not a member of the go team.

>TL;DR; setting it by default would move the things to a little bit more
>
>POSIXy, but
>possibly creating more hiddent deviations.

yeah but that wasn't my question was 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/B735D528-DD9B-4CF7-8C63-3593E81A88F0%40labrat.space.


Re: [go-nuts] Re: Windows syscall.Open() change to fix os.Rename() & .Remove()

2019-08-04 Thread Reto
On Wed, Jul 31, 2019 at 07:00:46PM -0700, Liam wrote:
> In this issue, Microsoft suggested that Go on Windows switch to Unix-like 
> behavior in Go 1.14:
> https://github.com/golang/go/issues/32088
> 
> I believe this will change early in pre-release 1.14.

May I inquire as to why you believe that?
Reading the issue itself, nothing points to a favorable opinion to your change 
request.
At least not from the comments there.

Most of the members / contributors either speak clearly against it, or are very
cautious.

The only thing is the go1.4 milestone, but milestones tend to be shifted
around quite often.

Can you please point to the discussion where this was decided?

-- 
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/20190804091533.o2lz7s7gpyqotaz2%40feather.localdomain.


Re: [go-nuts] Is it possible to simplify this snippet?

2019-05-01 Thread Reto
Granted, only if they are mutually exclusive...
Sorry, I missed the part of your mail mentioning that

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Is it possible to simplify this snippet?

2019-05-01 Thread Reto
On Wed, May 01, 2019 at 09:05:19AM -0700, jake6...@gmail.com wrote:
> There is nothing wrong with the code you presented. It is clear and readable.
> If you find that it clutters the function too much, then make it into it's 
> only utility function.

But it is wrong, even from a readability perspective.
You should not be writing an if chain like this, when we have case / switch 
operator.
*If* you insist of doing that, at least use `else if` so that you don't test 
every single test case if you know that only one can ever be true.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] the Dominance of English in Programming Languages

2019-04-29 Thread Reto
In my view you don't necessarily need to speak English, although it helps a lot.
Go uses utf-8 for all identifiers, so assuming you treat the keywords as blobs 
and just remember when to use which you should be fine.

The issue being more that all existing packages worth using are written with 
English identifiers, it being the defacto universal language of the world.
Same goes for the corresponding docs.

Writing programs in multiple languages just fragments the ecosystem for no real 
benefit.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Reto
On Wed, Apr 24, 2019 at 04:24:41PM -0500, Andrew Klager wrote:
> Is this so bad?

Yes, it's horrible as you'll loose any type information you had.
Meaning the next thing you naturally had to do was type cast it, which isn't 
the nicest syntax to begin with.
By then it's probably more work than just using if / else

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] [RFC][Gomobile] Wrote a series of posts on Gomobile

2019-04-24 Thread Reto
On Tue, Apr 23, 2019 at 08:46:15PM -0700, Girish Koundinya wrote:
> Any feedback is welcome :)

Well, for starters please return early from functions instead of nesting it 4 
levels deep, like in the example below (getContacts)
https://gist.githubusercontent.com/koundinya/a0d18ba4b830e3bb86f65aced026acbe/raw/f06fc5b8cd2dad7ec3af3f04de46c37337d4e6fb/contact_library.go

second, should in that same function the http.Get call ever fail you will panic

https://play.golang.org/p/KInGPmkNl3T

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] [CoC] screenshot images. Lazines or incompetence?

2019-03-11 Thread Reto Brunner
On Mon, Mar 11, 2019 at 07:46:27PM +0700, Shulhan wrote:
> I like to read email before sleep, keeping up-to-date with recent discussion 
> and what not.

How are you able to cope with mailing lists?
I find list messages seriously unreadable with the gmail app, due to the lack 
of threading.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] [CoC] screenshot images. Lazines or incompetence?

2019-03-11 Thread Reto Brunner
On Mon, Mar 11, 2019 at 04:36:32AM -0700, Manlio Perillo wrote:
> I consider polite to use the interleaved reply style and to trim the
> original message as much as possible.  It requires time and thinking,
> something that seems to be rare nowadays.

And yet you are right now also not doing it, adding to the problem.

Then again, not everyone uses a mail client where things like this is obvious, 
some prefer to use gmail for example. Now, gmail doesn't care about threading 
and automatically top / bottom posts (not sure which direction).

People aren't in the 80s anymore where a 72 char limit was nice, due to the 
screen size. Automatic line wrapping is a thing since a while, so are clients 
that strip (or hide) the quoted message trail.

So in short: get used to 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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] improve the reflection of golang

2018-11-19 Thread Reto Brunner
If you want to do that, there's already a package for it: 
https://github.com/jmoiron/sqlx

```
people := []Person{}
db.Select(, "SELECT * FROM person ORDER BY first_name ASC")
```

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: os.remove is slow

2017-12-04 Thread Reto Brunner
But why? Why does it matter if you are in the same dir or not when you glob?

On Mon, Dec 4, 2017, 20:34 Gabriel Forster 
wrote:

> Ding ding ding! We have a winner! Thank you so much.  That made a huge
> difference. It is now running ~20 seconds.
>
> The key is being in the same directory.
>
>
> On Monday, December 4, 2017 at 2:17:03 PM UTC-5, Patrick Smith wrote:
>
>> Does it make a difference if you first change directory to
>> /var/spool/directory, then glob * and unlink the resulting filenames,
>> without prepending the directory?
>>
> On Mon, Dec 4, 2017 at 11:05 AM, Gabriel Forster 
>> wrote:
>>
> Readdirnames wasn't much better. Now using globbing and syscall.Unlink
>>> which take ~1minute 30seconds. It is much better, but still a long way from
>>> perl's sub-20 seconds.
>>>
>>> package main
>>>
>>> import (
>>> "fmt"
>>> "path/filepath"
>>> "syscall"
>>> )
>>>
>>> func main() {
>>>
>>> upperDirPattern := "/var/spool/directory/*"
>>> matches, err := filepath.Glob(upperDirPattern)
>>>
>>> if err != nil {
>>> fmt.Println(err)
>>> }
>>>
>>> for _, file := range matches {
>>> syscall.Unlink(file)
>>> }
>>> }
>>>
>>>
>>>
>>> On Monday, December 4, 2017 at 12:50:54 PM UTC-5, Gabriel Forster wrote:

 What takes 18 seconds in a perl command:
 perl -e 'for(<*>){((stat)[9]<(unlink))}'

 is taking almost 8 minutes with the following code. Any ideas how I can
 speed this up?

 dir, err := os.Open("/var/spool/directory")
 if err != nil {
 fmt.Fprintf(w, "failed - " + err.Error())
 return
 }
 defer dir.Close()


 files, err := dir.Readdir(-1)
 if err != nil {
 fmt.Fprintf(w, "failed - " + err.Error())
 return
 }

 for _, file := range files {
 if file.Name() == "." || file.Name() == ".." {
 continue
 }

 os.Remove("/var/spool/directory/" + file.Name())
 }


 fmt.Fprintf(w, "success")


 --
>>> 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...@googlegroups.com.
>>
>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] [security] Go 1.8.4 and Go 1.9.1 are released

2017-10-04 Thread Reto Brunner
God no,
My system is managed by a *package manager* and I want it to stay that way

On Thu, Oct 5, 2017, 03:40 Bakul Shah  wrote:

> Would it make sense for Go to update itself? Something
> like "go update " that fetches a platform
> specific release, does some basic sanity tests and
> if all goes well, overwrites $GOROOT.
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: Deleting the /r/golang subreddit

2016-11-25 Thread Reto Brunner
God no!

Only because bradfitz has a problem with Reddit doesn't mean that all
others do

Squatting /r/golang and not handing moderation over would be a very unfair
move to those who liked *and still like* Reddit

If you don't wanna be a mod, fair enough, step down but leave us in peace!

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: Stalking people online for thought crimes! This is what the Go project has succumbed to!

2016-10-27 Thread Reto Brunner
At the CoC team,
You do realize that reddit is not actually yours to govern yes?
Reddit is being reddit... everywhere you can just post "anomalously"  the
atmosphere is rather more, well, outspoken than on a public mailing list.

Why don't you just deal with it and accept that there are other mentalities
than yours and let people have their personal life?

Aram, I find it very good that you chose a public mailing list instead of
contacting just the team. Like this there is the possibility to actually
have a discussion about when and where the code of conduct team should or
shouldn't issue "warnings" (or threads)

On Thu, 27 Oct 2016 at 22:32 Andrew Gerrand  wrote:

>
> On 28 October 2016 at 03:53, mjy  wrote:
>
> It's partly a cultural thing, I suppose. Some people consider the e-mail
> bland, others (like me) threatening. Someone should educate the CoC crew
> about these cultural, perhaps personality differences so they can improve
> their tone to avoid unnecessary escalation.
>
>
> We are definitely still learning, and I think it's clear that we missed
> the mark communicating with Aram here. It was not, and would never be, our
> intention to come across as threatening or harsh. I am dismayed by how this
> turned out. This will certainly inform our actions in the future.
>
> Andrew
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.