Re: [go-nuts] string matching

2021-04-02 Thread 'wagner riffel' via golang-nuts
On Thu Apr 1, 2021 at 4:45 PM -03, Sharan Guhan wrote: > r := regexp.MustCompile(`Core Count: [0-9]+`) > match := r.FindAllStringSubmatch(cmd_output, -1) As of the "efficiently" part, you should compile the regexp once instead of each call to ParseFillCpuInfo, a common practice is to use a package

Re: [go-nuts] package is not in GOROOT

2021-04-07 Thread 'wagner riffel' via golang-nuts
On Tue, 6 Apr 2021 19:39:00 -0400 rob wrote: > > This example is on Win10 using go 1.16.3 > > Now I've created a directory tree outside of ~/go/src.  I'm using ~ > to mean %userprofile%, as this is win10 > > ~/gcode/rpng/rpng.go > > ~/gcode/tokenize/tokenize.go > > ~/gcode/hpcalc2/hpcalc2.go

Re: [go-nuts] package is not in GOROOT

2021-04-09 Thread 'wagner riffel' via golang-nuts
On Wed, 7 Apr 2021 20:11:22 -0400 rob wrote: > Would it be a bad idea to use my ~go/src as a module? > I don't think so, I do have one global module like this for my own toys and throwaways programs. Yes, it would need to adjust your import paths according to the module, when I migrated to modu

Re: [go-nuts] Re: Give us const arrays please :)

2021-04-12 Thread 'wagner riffel' via golang-nuts
On Mon Apr 12, 2021 at 5:04 AM -03, Henry wrote: > The example you gave is actually a map[rune]bool in Go, and not an > array. I It's a Go array in form of a composite literal, see https://golang.org/ref/spec#Composite_literals -- You received this message because you are subscribed to the Googl

Re: [go-nuts] how to pass analyzer's flag with 'go vet -vettool'

2021-04-12 Thread 'wagner riffel' via golang-nuts
On Mon Apr 12, 2021 at 10:23 AM -03, Xiangdong Ji wrote: > Hi, > > I'm trying to run "go vet -vettool=$(which fieldalignment) ./..." for a > large project, and wish to turn its '-fix' option on, wondering how to > pass > that option? Hi Xiangdong, I found that surprising that even docs didn't ment

Re: [go-nuts] Why does Go ignore HTTP_PROXY and HTTPS_PROXY if the proxy address is localhost

2021-04-13 Thread 'wagner riffel' via golang-nuts
On Tue Apr 13, 2021 at 2:14 PM -03, Orson Cart wrote: > Can anyone explain the reasoning behind this? It rather interferes with > debugging traffic using a local proxy like Fiddler. > My guess here it's for preventing the remote from tricking the proxy to make request to internal services that cou

Re: [go-nuts] Why does Go ignore HTTP_PROXY and HTTPS_PROXY if the proxy address is localhost

2021-04-13 Thread 'wagner riffel' via golang-nuts
On Tue Apr 13, 2021 at 7:07 PM UTC, Orson Cart wrote: > I'm perplexed :( > Did you tried the /etc/hosts? I think that would do it, if not, something like this may do the trick: if debug { t := http.DefaultTransport.(*http.Transport) t.Proxy = func(r *http.Request) (*url.URL, error

Re: [go-nuts] how to pass analyzer's flag with 'go vet -vettool'

2021-04-14 Thread 'wagner riffel' via golang-nuts
On Wed Apr 14, 2021 at 12:25 AM -03, Xiangdong Ji wrote: > I tried to modify fieldalignment to turn its '-fix' option on by > default, change worked as expected if running fieldalignment as a > standalone utility, but no rewriting is applied when running it as a > tool of 'go vet', could any expert

Re: [go-nuts] Why fmt.Println(math.Sqrt2) gives ...0951 not ...0950?

2021-05-01 Thread 'wagner riffel' via golang-nuts
On Sat May 1, 2021 at 11:12 AM -03, Kamil Ziemian wrote: > Can you guide me to some materials about const in Go? Or maybe I should > finally read Go spec, which I avoid for a long time? > You shouldn't avoid to read the spec, it's not as complicated as others languages, and it's a great source of

Re: [go-nuts] x/tools error while trying to install

2021-05-07 Thread 'wagner riffel' via golang-nuts
On Fri May 7, 2021 at 11:10 AM -03, Eric Garcia wrote: > Was trying to install all the tools, and hit the following errors. > > go version 1.16.3 > > ``` > go get -u golang.org/x/tools/... > I think with go1.16 and later the correct way of installing programs is with go install, it builds clean fo

Re: [go-nuts] Read N bytes from a TLS stream and block the caller while still respecting the deadline

2021-11-30 Thread 'wagner riffel' via golang-nuts
On Tue Nov 30, 2021 at 11:20 PM CET, LastName Almaember wrote: > It's meant to first read a nine-byte header (8 bits of a type field > followed by a 64 bit length). In theory, it should work fine, but it > always immediately returns InputTooShort (right at the first check). io.Readers returns up t

Re: [go-nuts] Pointer to a pointer

2022-03-10 Thread 'wagner riffel' via golang-nuts
On Thu Mar 10, 2022 at 12:41 PM CET, Manlio Perillo wrote: > Interesting example, thanks. > > But how does `type self *self` works? If I remember correctly, it is not > discussed in the Language Specification and in The Go Programming Language > book. > I don't think it's mentioned in the specifi

Re: [go-nuts] float exactness

2022-04-10 Thread 'wagner riffel' via golang-nuts
On Sat Apr 9, 2022 at 3:56 PM CEST, 'Jack Li' via golang-nuts wrote: > Why literal operation is exact, variable is not? > > fmt.Println(0.1 + 0.2) // 0.3 exactly > fmt.Println(x + y) // 0.30004 > Both aren't exact because floats can't represent 0.3 exactly, they differ because literals

Re: [go-nuts] Packages for Accessing .a Archives?

2022-04-10 Thread 'wagner riffel' via golang-nuts
On Sun Apr 10, 2022 at 4:23 AM CEST, jlfo...@berkeley.edu wrote: > Other than what's in the Go distribution, I haven't been able to find any > packages for accessing .a archives. Is there anything else out there? > Google wasn't helpful. > > Cordially, > Jon Forrest > I found these using https://p

Re: [go-nuts] Executing a tar command from within a Go program

2022-04-20 Thread 'wagner riffel' via golang-nuts
On Wed Apr 20, 2022 at 6:16 PM CEST, Dean Schulze wrote: > I need to execute this tar command > > *tar xzf dir1/dir2/somefile.tgz --directory=dir1/dir2/* > Did you considered using the packages "archive/tar" and "compress/gzip" to achive this? > *argStr := "xzf dir1/dir2/somefile.tgz --directory=

Re: [go-nuts] Executing a tar command from within a Go program

2022-04-20 Thread 'wagner riffel' via golang-nuts
Also, the Output method only returns what was wrote to stdout, tar argument parsing errors are probably in stderr, using CombinedOutput() has better effect to debug. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group a

Re: [go-nuts] For range loop variable passing by reference to go routine causes memory leak

2022-10-08 Thread 'wagner riffel' via golang-nuts
On 08/10/2022 22:56, davy zhang wrote: Original post on stackoverflow: https://stackoverflow.com/questions/73985794/for-range-loop-variable-passing-by-reference-to-go-routine-causes-memory-leak Code for reproducing the problem: https://go.dev/play/p/7Xzx1Aauzhh go version go1.19 darwin/amd64

Re: [go-nuts] get function body comments using ast

2022-10-10 Thread 'wagner riffel' via golang-nuts
On 10/9/22 11:09, Dmitry Belyaev wrote: For a function like below I'd get only *example // doc comment*, // doc comment func example() {   // body comment   < looking to extract this comment } but I am looking also to extract *// body comment*. Please advise on how to extract function nam

Re: [go-nuts] Newbie question

2023-01-10 Thread &#x27;wagner riffel&#x27; via golang-nuts
On 1/10/23 11:42, Daniel Jankins wrote: Hi, Why can you update a value in a map struct? Sort answer, because m["foo"] is not addressable, but you can have the desired behavior using a temp variable: func f() { m := make(map[string]struct{ i int }) x := m["foo"] x.i

Re: [go-nuts] shadowing of types by variables

2023-01-16 Thread &#x27;wagner riffel&#x27; via golang-nuts
On 1/13/23 07:20, Gorka Guardiola wrote: According to the spec it seems like it is legal to shadow a type with a variable, even a builtin type. Is there any specific rationale for this? I guess that it makes scoping checks easier and faster, but still. I don't think there is any special rati

Re: [go-nuts] Re: Is it expected that signal.NotifyContext() changes the execution thread?

2023-10-03 Thread &#x27;wagner riffel&#x27; via golang-nuts
On Tue Oct 3, 2023 at 05:54 AM UTC, Kurtis Rader wrote: > Thank you to Ian and TheDiveO. I don't understand why functions like > gocv.io/x/gocv.NewWindow() have to run on the initial OS thread (at least > on macOS). It's common for C and C++ libraries to use TLS (thread local storage) to attach d

Re: [go-nuts] Why no signed conversions in binary.ByteOrder?

2024-07-27 Thread &#x27;wagner riffel&#x27; via golang-nuts
a2800276 wrote: > Just out of curiosity, does anyone have a good rationale as to why there > are only unsigned conversions available `binary.ByteOrder`? It would seem > that this functionality is there to avoid dumb careless errors doing byte > order conversions, but this design forces me to ha

Re: [go-nuts] Why no signed conversions in binary.ByteOrder?

2024-07-28 Thread &#x27;wagner riffel&#x27; via golang-nuts
a2800276 wrote: > I agree it has no technical merit. It can't do better, but it avoid having > to think about the type mismatch. The functionality provided by ByteOrder > is fairly simple to begin with, I assume its whole purpose is to reduce > cognitive load/avoid dumb mistakes. My assumption

Re: [go-nuts] Running only one sub-benchmark

2024-08-06 Thread &#x27;wagner riffel&#x27; via golang-nuts
Jochen Voss wrote: > Now I just want to run one of these sub-benchmarks. I tried -bench > '^BenchmarkTextLayout/CFFSimple1$' but this runs two of the benchmarks: > > > go test -run=^$ -bench '^BenchmarkTextLayout/CFFSimple1$' > goos: darwin > goarch: arm64 > pkg: seehuhn.de/go/pdf/graphics > Ben