Re: [go-nuts] How to automatically embed module name from go.mod into executables?

2021-10-08 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2021-10-08 at 16:36 -0700, Christian Stewart wrote: > Is there a way to /not/ have this information in the binary? > You can use the garble tool[1] to strip/garble things like this. $ cd golang.org/x/tools/cmd/stringer $ garble build . $ go version -m stringer stringer: unknown

Re: [go-nuts] Loading Certificate and Key from string not file for HTTPs server

2021-10-08 Thread Sam Caldwell
Yeah. I have a proof of concept complete. It's a bit more than 3 lines. It's just under 100 lines. Error handling, etc. 1. This needs to be something devs can use without a lot of effort or they just push back and use file-based HTTPS servers. 2. This needs to have no loss of

Re: [go-nuts] Re: Questions about documentation of Go standard library

2021-10-08 Thread Ian Lance Taylor
On Fri, Oct 8, 2021 at 12:36 PM Kamil Ziemian wrote: > > I found unimportant typo in English part of the documentation of "fmt". How > can I correct it? GitHub pull request or open issue "Unimportant typos in > documentation"? I don't know how I should treat such unimportant typo. You can send

Re: [go-nuts] How to automatically embed module name from go.mod into executables?

2021-10-08 Thread Christian Stewart
Is there a way to /not/ have this information in the binary? On Friday, October 8, 2021 at 10:47:06 AM UTC-7 jayc...@google.com wrote: > Good news! The main package path, the containing module, and all of the > dependencies and their versions are already embedded in Go executables. You > can

Re: [go-nuts] Re: Questions about documentation of Go standard library

2021-10-08 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2021-10-08 at 15:33 -0700, Kamil Ziemian wrote: > Hello, > > I now read documentation of "fmt" package and in "Format errors" ( > https://pkg.go.dev/fmt@go1.17.2#hdr-Format_errors) we have > Invalid or invalid use of argument index: %!(BADINDEX) > Printf("%*[2]d", 7):

Re: [go-nuts] Re: Questions about documentation of Go standard library

2021-10-08 Thread Martin Schnabel
Hi Kamil, you can probably read it as Invalid argument index or invalid use of argument index. Hope that helps. On 10/9/21 12:33 AM, Kamil Ziemian wrote: Hello, I now read documentation of "fmt" package and in "Format errors" (https://pkg.go.dev/fmt@go1.17.2#hdr-Format_errors) we have

Re: [go-nuts] Re: Questions about documentation of Go standard library

2021-10-08 Thread Kamil Ziemian
Hello, I now read documentation of "fmt" package and in "Format errors" (https://pkg.go.dev/fmt@go1.17.2#hdr-Format_errors) we have Invalid or invalid use of argument index: %!(BADINDEX) Printf("%*[2]d", 7): %!d(BADINDEX) Printf("%.[2]d", 7): %!d(BADINDEX) I cannot

Re: [go-nuts] Re: Questions about documentation of Go standard library

2021-10-08 Thread Kamil Ziemian
Hello, I found unimportant typo in English part of the documentation of "fmt". How can I correct it? GitHub pull request or open issue "Unimportant typos in documentation"? I don't know how I should treat such unimportant typo. Best Kamil piątek, 8 października 2021 o 00:53:11 UTC+2 Kamil

Re: [go-nuts] Testing: what's the difference between package x and x_test?

2021-10-08 Thread Ian Lance Taylor
On Fri, Oct 8, 2021 at 11:34 AM Davi Marcondes Moreira wrote: > > Suppose a project has a package called abc, and this package has a few test > files (*_test.go files). > > I've noticed two different patterns when writing tests. Some files may > declare its own package at the top of the file as

[go-nuts] Re: Testing: what's the difference between package x and x_test?

2021-10-08 Thread Sean Liao
>From https://pkg.go.dev/cmd/go#hdr-Test_packages > Test files that declare a package with the suffix "_test" will be compiled as a separate package, and then linked and run with the main test binary. Practically, this means no access to unexported things in the package On Friday, October 8,

[go-nuts] Testing: what's the difference between package x and x_test?

2021-10-08 Thread Davi Marcondes Moreira
Suppose a project has a package called abc, and this package has a few test files (*_test.go files). I've noticed two different patterns when writing tests. Some files may declare its own package at the top of the file as below: package abc While others may declare its package as: package

[go-nuts] Re: TCP max segment size

2021-10-08 Thread Sean Liao
net.TCPConn.SyscallConn exposes the fd which you can use with sycalls On Friday, October 8, 2021 at 7:05:40 PM UTC+2 bjeun...@gmail.com wrote: > Hi, > > looking at the net package of the standard library, I don't see a way to > set the tcp max segment size. Surely, one can create a tcp

Re: [go-nuts] How to automatically embed module name from go.mod into executables?

2021-10-08 Thread 'Jay Conrod' via golang-nuts
Good news! The main package path, the containing module, and all of the dependencies and their versions are already embedded in Go executables. You can read that info with `go version -m path/to/exe`. $ go install golang.org/x/tools/cmd/stringer@latest $ go version -m ~/go/bin/stringer

[go-nuts] TCP max segment size

2021-10-08 Thread Brieuc Jeunhomme
Hi, looking at the net package of the standard library, I don't see a way to set the tcp max segment size. Surely, one can create a tcp connection manually and set the segment size by using the syscall package, but that approach prevents them from reusing higher level packages that want a

[go-nuts] How to automatically embed module name from go.mod into executables?

2021-10-08 Thread Zigster Programmer
One of my pet peeves with all executables, not just those created with go, is that determining their origin can easily be lost in the mists of time. This is a problem because I might "go get" some source code and install it, then not update it for many years. Then when I have some need to do

Re: [go-nuts] Draining http response bodies

2021-10-08 Thread Amnon
Whatever the OS, the crucial question is whether the TCP connections get reused, or whether a new TCP (and potentially TLS) connection has to be negotiated, involving multiple round trips to the server. Someone has kindly pointed out that the docs do spell out the behaviour - I just missed the

[go-nuts] unmarshal xml to a struct edmx:Edmx

2021-10-08 Thread RS
I want to unmarshal an xml data to a data structure. Problem is the following This xml comes from a Odata Server and has fields "edmx:Edmx". How should the fields of struct be named? I observe that the fields name of struct representing xml should be the same name as xml field name. Now how

Re: [go-nuts] Can generics help me make my library safer?

2021-10-08 Thread mi...@ubo.ro
I'm using the library with a nosql. I provided the sql example b/c it's part of the std library. I like rog's solution(especially on the generic Resource type) but to reduce friction and make it more idiomatic I would need to be able to define the select arguments in the return func (after the

Re: [go-nuts] Loading Certificate and Key from string not file for HTTPs server

2021-10-08 Thread Sean Liao
It's only 3 lines excluding error handling if you just want to use a static string. And you'll likely want to setting up your own http.Server anyway to have control over timeouts (and also your own mux to prevent leaking debug handlers). In practice you may actually want o use

Re: [go-nuts] Loading Certificate and Key from string not file for HTTPs server

2021-10-08 Thread Sam Caldwell
Sorry for the delayed response. I needed to noodle on this option and talk to some of the devs who would need to implement this. 1. Setting up an http.Server{} and tls.Config will work. But it is a lot of effort for devs who want to focus on the business logic. 2. This creates more code the

Re: [go-nuts] Draining http response bodies

2021-10-08 Thread David Riley
On Oct 7, 2021, at 3:36 AM, Amnon wrote: > > Is it necessary for a http client to fully read the http response body? > > Opinion on the Go forums seems divided > https://forum.golangbridge.org/t/do-i-need-to-read-the-body-before-close-it/5594 > > But a simple benchmark