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

2024-08-06 Thread 'wagner riffel' 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

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

2024-07-28 Thread 'wagner riffel' 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] Why no signed conversions in binary.ByteOrder?

2024-07-27 Thread 'wagner riffel' 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] Re: Is it expected that signal.NotifyContext() changes the execution thread?

2023-10-03 Thread 'wagner riffel' 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] shadowing of types by variables

2023-01-16 Thread 'wagner riffel' 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] Newbie question

2023-01-10 Thread 'wagner riffel' 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] 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] For range loop variable passing by reference to go routine causes memory leak

2022-10-08 Thread &#x27;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] Executing a tar command from within a Go program

2022-04-20 Thread &#x27;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] Executing a tar command from within a Go program

2022-04-20 Thread &#x27;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] Packages for Accessing .a Archives?

2022-04-10 Thread &#x27;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] float exactness

2022-04-10 Thread &#x27;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] Pointer to a pointer

2022-03-10 Thread &#x27;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] Read N bytes from a TLS stream and block the caller while still respecting the deadline

2021-11-30 Thread &#x27;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] x/tools error while trying to install

2021-05-07 Thread &#x27;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] Why fmt.Println(math.Sqrt2) gives ...0951 not ...0950?

2021-05-01 Thread &#x27;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] how to pass analyzer's flag with 'go vet -vettool'

2021-04-14 Thread &#x27;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 does Go ignore HTTP_PROXY and HTTPS_PROXY if the proxy address is localhost

2021-04-13 Thread &#x27;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] Why does Go ignore HTTP_PROXY and HTTPS_PROXY if the proxy address is localhost

2021-04-13 Thread &#x27;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] how to pass analyzer's flag with 'go vet -vettool'

2021-04-12 Thread &#x27;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] Re: Give us const arrays please :)

2021-04-12 Thread &#x27;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] package is not in GOROOT

2021-04-09 Thread &#x27;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] package is not in GOROOT

2021-04-07 Thread &#x27;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] string matching

2021-04-02 Thread &#x27;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] prevent unnecessary escape to heap

2021-02-05 Thread Wagner Riffel
On Thu, Feb 4, 2021 at 10:32 PM Steve Roth wrote: > > How can I implement a writeByte function, against an unknown io.Writer > implementation, that doesn't allocate heap memory? > The only way I'm aware of achieving this is proving to the compiler that buf is safe to be kept by w by moving buf t

Re: [go-nuts] Failed to install golang.org/x/tools

2021-02-05 Thread Wagner Riffel
On Mon, Feb 1, 2021 at 11:36 PM eric...@arm.com wrote: > > Os: ubuntu 18.04 > Arch: arm64 linux > go version: go1.15.7 > What did I do: > $ go get -u golang.org/x/tools/... > package mvdan.cc/gofumpt/format: unrecognized import path > "mvdan.cc/gofumpt/format": reading https://mvdan.cc/gofumpt/f

Re: [go-nuts] Packet parsing in Go

2020-04-22 Thread wagner riffel
On Tue, 21 Apr 2020 02:22:37 -0700 (PDT) Rakesh K R wrote: > In C, we used to typecast this array of uint8_t to predefined > structure. > This is very bad even for a C program, as soon as you dereference pointer to such structure it's an undefined behavior, and not portable even on LE architect

Re: [go-nuts] libgo is more fast that grouting.

2020-03-16 Thread wagner riffel
On Mon, 16 Mar 2020 20:13:10 +0800 "'Benjamin' via golang-nuts" wrote: > How do you all think about it? > IMO there's no such thing as "Go-style concurrency" if you don't have `select`, which doesn't looks like this library provides (as many others). —wagner -- You received this message becau

Re: [go-nuts] Why can't I send byte array to golang TCP server using java netty client?

2020-03-11 Thread wagner riffel
I think that your problem is here: buffer := make([]byte, 6), conn.Read reads up to len(bufer) before unblocking, and apparently you're trying to decode an int32, which is 4 bytes long, so your Read call is waiting for those 2 bytes from your java client to continue. —wagner -- You received this

Re: [go-nuts] What is the output of objdump?

2020-02-27 Thread wagner riffel
On Thu, 27 Feb 2020 19:03:02 -0800 (PST) bucha...@gmail.com wrote: > Can someone please explain the columns printed by "go tool objdump"? > instruction. I'm not sure what columns 2, 3, and 5 are. Column $2 is the memory address offset, $3 is the entire instruction encoded in hexadecimal, $5 is a

Re: [go-nuts] manifest file of releases

2019-12-06 Thread Wagner Riffel
On Thu Dec 5, 2019 at 8:27 AM wrote: > I would hope there would be a JSON file from which I could use to monitor > releases and obtain download URLs. Something similar to what CoreOS does: > https://coreos.com/releases/releases.json GET https://golang.org/dl/?mode=json, then your download link w

Re: [go-nuts] Get tmp stuff in $GOTMPDIR instead of /tmp?

2019-08-22 Thread Wagner Riffel
On Thu, Aug 22, 2019 at 12:33 PM Wagner Riffel wrote: > go build uses GOCACHE, not GOTMPDIR. See go help environment. Sorry, i was wrong, those are supposed to be temporary files, and they are going correctly to GOTMPDIR for me, not sure what your problem is. - wgr -- You received t

Re: [go-nuts] Get tmp stuff in $GOTMPDIR instead of /tmp?

2019-08-22 Thread Wagner Riffel
On Thu, Aug 22, 2019 at 11:54 AM wrote: > > Am I using things wrong? go build uses GOCACHE, not GOTMPDIR. See go help environment. - wgr -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails f

Re: [go-nuts] In module mode, where does "go install" install executables

2019-06-25 Thread Wagner Riffel
> > I'd bet the default GOPATH, that is $HOME/go BR. -- 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 discu

Re: [go-nuts] Re: cannot find package "text/template"

2019-06-13 Thread Wagner Riffel
Hi Tenney, clearly something went wrong with /src directory, you reported your compiler to be go1.12, so it'd be a better idea to download the go tree from go1.12 release branch instead of tip, https://github.com/golang/go/tree/release-branch.go1.12 -- You received this message because you are su

Re: [go-nuts] How to confirm a function is NOT compiled into a go binary

2019-06-08 Thread Wagner Riffel
This is totally possible, you can either use 'go tool nm' as suggest, or 'go tool objdump', both tools can answer this question. go tool objdump -s 'pkgname/internal' a.out go tool nm a.out | grep 'pkgname/internal' Be aware that testing against the shown examples, neither A() will be present, by d

Re: [go-nuts] Is this a bug?

2019-05-24 Thread Wagner Riffel
It's not a bug, FormatterA and FormatterB method has different signatures, they are not identical, one wants Format(StringerA) other Format(StringerB), thus your Format type only implements FormatterA but Print wants a FormatterB. -- You received this message because you are subscribed to the Goo

Re: [go-nuts] What happens to global vars when main() ends ?

2019-05-03 Thread Wagner Riffel
Last "kkk" print It's not a compiler error due GC, it's just a scoping rule. You shouldn't rely on any GC behaviour, GC is not even definied in Go language spec and its behaviour changes almost every release. BR. -- You received this message because you are subscribed to the Google Groups "golan

Re: [go-nuts] What happens to global vars when main() ends ?

2019-05-03 Thread Wagner Riffel
> Does Go GC destroy all global vars prior to the end of main() ? What do you expected to happen? it makes no sense GC do any work, at moment a process exits it's OS's job to unmmap allocated pages. FWIW if race detector is enabled runtime does one thing before exit syscall is invoked: if provide

Re: [go-nuts] When would you use single quotes?

2019-02-06 Thread Wagner Riffel
'⌘' is of type rune (aka int32), "⌘" and `⌘` are of type string, both takes more than 3 bytes. -- 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+unsubsc

Re: [go-nuts] Re: why map the key type must not be a function, map, or slice

2019-01-26 Thread Wagner Riffel
not be used >> as a key use >> >> 在 2019年1月25日星期五 UTC+8下午11:31:57,Victor Giordano写道: >>> >>> Yeah, i got the idea. I had already researched about it and what you >>> can do about it. >>> <https://stackoverflow.com/questions/50730331/mapping

Re: [go-nuts] Producer-Consumer with Goroutines

2019-01-25 Thread Wagner Riffel
;s output before the consumer's, then > this example still can't guarantee it; for example: > https://play.golang.org/p/2sb67Qf5IPd > > the only synchronization guarantee is the moment of exchange on the channel. > > On Fri, Jan 25, 2019 at 3:27 AM Wagner Riffel wrote: >

Re: [go-nuts] Re: why map the key type must not be a function, map, or slice

2019-01-25 Thread Wagner Riffel
you can "employ" any custom type as key but the ones that doesn't defines equality operations, see https://golang.org/ref/spec#Comparison_operators as Ian already pointed out, you just can't build your custom type on top of func, map or slice to be a valid key, anything else you can. On Fri, Jan 2

Re: [go-nuts] Producer-Consumer with Goroutines

2019-01-25 Thread Wagner Riffel
maybe it's the way you approached the problem, here is a perhaps cleaner way to achieve desired output, https://play.golang.org/p/3a4lxbjdQAr BR. On Thu, Jan 24, 2019 at 7:12 PM diego patricio wrote: > Hi all, i'am just learning Go and goroutines, I have three goroutines > (main, producer, cons

Re: [go-nuts] Regarding Invalid UTF-8 characters

2019-01-25 Thread Wagner Riffel
there is nothing to do with special characters in the example you shown, your xml data is just invalid xml, you're missing root element, just add it and it should work: CPUêÿ btw here is a short version of your program on playground, https://play.golang.org/p/PhKgVXIcWZl On Fri, Jan 25, 2019 at 6:

Re: [go-nuts] Re: Is it possible to export a variable from main package? If impossible, why?

2019-01-23 Thread Wagner Riffel
packages have nothing to do with files, if you are on some directory you don't need to import any package, just use Number on other files On Thu, Jan 24, 2019, 3:36 AM 伊藤和也 wrote: > I couldn't import "main" package to other packages to use the variable > "Number" and I try to use "Number" in ma

Re: [go-nuts] Can I say that a pointer is a reference or memory address to a value?

2019-01-09 Thread Wagner Riffel
i think the term reference is misleading, pointers holds a memory address, but they are variables, have their own space in memory. var i int var p1, p2 = &i, &i fmt.Printf("%p, %p, %p", &i, &p1, &p2) // 0x1000, 0x1004, 0x1008 while in c++ references variables for example, address are s

Re: [go-nuts] Trouble with exiting a for loop that contains bufio.NewScanner.Scan()

2018-12-30 Thread Wagner Riffel
Scan() returns false when it reaches EOF or an error, so with what you provided i assume you're missing to check that. for ns.Scan() { ... } or for { if !ns.Scan() { break } -wgr On Sun, Dec 30, 2018 at 10:36 PM Trig wrote: > > I'm currently utilizing the bufio.NewScanner to read ASCII dat

Re: [go-nuts] Forking/transfering a repository and import paths

2018-12-12 Thread Wagner Riffel
Go has nothing to do with github, you can have any import path and how many repos you like as long as it exists on your file system inside $GOPATH/src -wgr On Wed, Dec 12, 2018, 10:13 AM Sotirios Mantziaris wrote: > Hi, > > i want to move a repo from my github account to another one. Goal is to

Re: [go-nuts] How to add a new operator

2018-12-09 Thread Wagner Riffel
define operator. -wgr On Sun, Dec 9, 2018, 10:27 AM Claygod wrote: > Hello, > > I want to try adding a new operator. Tell me, in which packages you need > to edit the code? > Maybe once a similar question was discussed, then please give a link > > -- > You received this message because you are s

Re: [go-nuts] Unable to view go-review.googlesource.com on Firefox 60.x

2018-11-16 Thread Wagner Riffel
I'm either on 60.3 under linux and it's working fine. On Fri, Nov 16, 2018 at 1:25 PM Sam Whited wrote: > > FWIW, I'm on 65 nightly and haven't noticed any problems (including back when > 63 was the nightly release). > > —Sam > > On Fri, Nov 16, 2018, at 09:22, Ian Davis wrote: > > Hi all, > > >

Re: [go-nuts] Where are the dependencies saved when we use go mod

2018-10-08 Thread Wagner Riffel
> Where is the dependent github.com/stretchr/testify/assert downloaded - I dont > see it downloaded any where. it still download physically, it's under $GOPATH/pkg/mod On Mon, Oct 8, 2018 at 5:55 PM pprasanthi via golang-nuts wrote: > > I followed below steps to run tests in go mod. In this proce