Re: [go-nuts] Question about adding new feature to go (FreeBSD/netlink) and compliation

2024-09-04 Thread Martin Stiemerling
> Am 04.09.2024 um 06:58 schrieb Mark Geisert : > > Maybe a red herring, but you do have > GOROOT='/usr/local/go122' > in the output of go env in your original post. This is set automatically by go itself. I’ve also stumbled across this and double-checked if GOROOT is set by my or the shell.

Re: [go-nuts] Question about adding new feature to go (FreeBSD/netlink) and compliation

2024-09-04 Thread Mark Geisert
Maybe a red herring, but you do have GOROOT='/usr/local/go122' in the output of go env in your original post. ..mark On Tuesday, September 3, 2024 at 10:40:58 AM UTC-7 Martin Stiemerling wrote: > > > > Am 03.09.2024 um 19:27 schrieb Ian Lance Taylor : > > > > On Tue, Sep 3, 2024 at 10:25 AM Mar

Re: [go-nuts] Question about adding new feature to go (FreeBSD/netlink) and compliation

2024-09-03 Thread Martin Stiemerling
> Am 03.09.2024 um 19:27 schrieb Ian Lance Taylor : > > On Tue, Sep 3, 2024 at 10:25 AM Martin Stiemerling > wrote: >> >>> Am 03.09.2024 um 19:19 schrieb Ian Lance Taylor : >>> >>> On Tue, Sep 3, 2024 at 10:07 AM Martin Stiemerling >>> wrote: > Am 03.09.2024 um 18:50 s

Re: [go-nuts] Question about adding new feature to go (FreeBSD/netlink) and compliation

2024-09-03 Thread Martin Stiemerling
> Am 03.09.2024 um 19:19 schrieb Ian Lance Taylor : > > On Tue, Sep 3, 2024 at 10:07 AM Martin Stiemerling > wrote: >> >> >> >>> Am 03.09.2024 um 18:50 schrieb Ian Lance Taylor : >>> >>> On Tue, Sep 3, 2024 at 9:03 AM Martin Stiemerling >>> wrote: FreeBSD has since a while also

Re: [go-nuts] Question about adding new feature to go (FreeBSD/netlink) and compliation

2024-09-03 Thread Ian Lance Taylor
On Tue, Sep 3, 2024 at 10:07 AM Martin Stiemerling wrote: > > > > > Am 03.09.2024 um 18:50 schrieb Ian Lance Taylor : > > > > On Tue, Sep 3, 2024 at 9:03 AM Martin Stiemerling > > wrote: > >> > >> FreeBSD has since a while also support for the netlink facility, similar > >> to Linux. For Linux t

Re: [go-nuts] Question about adding new feature to go (FreeBSD/netlink) and compliation

2024-09-03 Thread Martin Stiemerling
> Am 03.09.2024 um 18:50 schrieb Ian Lance Taylor : > > On Tue, Sep 3, 2024 at 9:03 AM Martin Stiemerling > wrote: >> >> FreeBSD has since a while also support for the netlink facility, similar to >> Linux. For Linux there is support in go via the syscall pkg for working with >> Linux's net

Re: [go-nuts] Question about adding new feature to go (FreeBSD/netlink) and compliation

2024-09-03 Thread Ian Lance Taylor
On Tue, Sep 3, 2024 at 9:03 AM Martin Stiemerling wrote: > > FreeBSD has since a while also support for the netlink facility, similar to > Linux. For Linux there is support in go via the syscall pkg for working with > Linux's netlink, but not yet for FreeBSD > > I have started to add the FreeBSD

[go-nuts] Question about adding new feature to go (FreeBSD/netlink) and compliation

2024-09-03 Thread Martin Stiemerling
Hi all, FreeBSD has since a while also support for the netlink facility, similar to Linux. For Linux there is support in go via the syscall pkg for working with Linux's netlink, but not yet for FreeBSD I have started to add the FreeBSD part to go's syscall package and fixed some errors, but run i

Re: [go-nuts] question about HACKING.md

2024-07-18 Thread Ian Lance Taylor
On Thu, Jul 18, 2024 at 11:29 AM Leah Stapleton wrote: > > In the document HACKING.md > (https://github.com/golang/go/blob/master/src/runtime/HACKING.md), it states > that we can determine if we're running on the user or system stack by running > `getg() == getg().m.curg`. > > However if the ou

[go-nuts] question about HACKING.md

2024-07-18 Thread Leah Stapleton
In the document HACKING.md (https://github.com/golang/go/blob/master/src/runtime/HACKING.md), it states that we can determine if we're running on the user or system stack by running `getg() == getg().m.curg`. However if the output of that equality check is true, does that mean we're on user o

[go-nuts] question about src/cmd/go/internal/script/cmds_posix.go and windows

2024-05-13 Thread hnak...@gmail.com
Hi, I found that https://github.com/golang/go/blob/07fc59199b9522bfe0d14f35c4391394efc336c9/src/cmd/go/internal/script/cmds_posix.go has the build tag //go:build unix || windows Is windows really needed here? (I suppose not) isETXTBSY is also defined in https://github.com/golang/go/blob/07fc59199

[go-nuts] question about TestPageAllocAlloc, AllFree1

2024-05-07 Thread Leah Stapleton
I have a question about scavenging arising one of the runtime tests in runtime/mpagealloc.go. The test in question is the " AllFree1" test case in TestPageAllocAlloc. According to my understanding, in the runtime, there is a distinction between reclaiming memory and scavenging memory. Reclaimi

[go-nuts] Question about httptrace synchronization

2023-10-26 Thread Eli Lindsey
Example code (note that it won’t actually execute in the playground since it’s making network calls): https://play.golang.com/p/V9Z-ErjgICW My assumption was that this code is a potential data race and requires additional synchronization on t. net/http/httptrace in particular says: "Functions m

Re: [go-nuts] Question in Converting float64 to uint64

2023-10-25 Thread Eli Lindsey
Float64Bits preserves the underlying representation. The numeric value of the uint64 it returns has little significance. You’d typically use it when serializing floats, when wanting to make manual changes to the float’s representation, and so on. uint64(f) cares about preserving the numeric val

[go-nuts] Question in Converting float64 to uint64

2023-10-25 Thread Xie Yuchen
Hi Guys, recently, I've been learning the number types conversion. I learned about the ieee 754 round to even when golang converts from uint64 to float64. However, when I want to convert the float64 to uint64 back, there is a different between functions: `math.Float64Bits` and use `uint64(f)`.

Re: [go-nuts] Question about runtime.Pinner

2023-10-12 Thread 'Michael Knyszek' via golang-nuts
On Thursday, October 12, 2023 at 9:55:12 AM UTC-4 Ian Lance Taylor wrote: On Thu, Oct 12, 2023 at 5:06 AM Pascal Costanza wrote: > > I have a question about runtime.Pinner: The documentation states that you can only pin an object when it’s the result of calling new, taking the address of a

Re: [go-nuts] Question about runtime.Pinner

2023-10-12 Thread Ian Lance Taylor
On Thu, Oct 12, 2023 at 5:06 AM Pascal Costanza wrote: > > I have a question about runtime.Pinner: The documentation states that you can > only pin an object when it’s the result of calling new, taking the address of > a composite literal, or taking the address of a local variable. > > At the sa

[go-nuts] Question about runtime.Pinner

2023-10-12 Thread Pascal Costanza
Hi, I have a question about runtime.Pinner: The documentation states that you can only pin an object when it’s the result of calling new, taking the address of a composite literal, or taking the address of a local variable. At the same time, the Go language specification states that a slice cr

[go-nuts] Question on cover tool

2023-02-12 Thread Tharaneedharan Vilwanathan
Hi, I was trying the cover tool with this: https://go.dev/blog/cover. I got the HTML output that I can browse and get the coverage (count) details but I am wondering if there is a way to see the count of each line along with the actual line in text output format (i.e. not html). I see this example

[go-nuts] Question on 'src/internal/singleflight': The return result of the ForgetUnshared method seems to be inaccurate

2022-09-20 Thread atomic
hello I find that the `src/internal/singleflight/singleflight.go ForgetUnshared()` method returns results that are not always expected For this I wrote a test code, I copied the code in the src/internal/singleflight/singleflight.go file to the main package, and wrote a main function to test it

[go-nuts] Question on 'cmd/compile: handle partially overlapping assignments' behavior on ARM64.

2022-09-19 Thread Josh Peterson
I stumbled across a performance regression on ARM64 for go 1.18.6 and 1.19.1 that wasn't present in earlier releases. In the following benchmark, you can see `BenchmarkSliceOfArray` experiences a 70% increase in execution time while `BenchmarkSliceOfInt` remains unchanged. BenchmarkSliceOf

Re: [go-nuts] Question regarding Golang Interfaces and composite struct

2022-04-28 Thread burak serdar
On Thu, Apr 28, 2022 at 9:49 AM Glen D souza wrote: > Consider the following piece of code > > type Dog struct { > } > > type Walker interface { > Walks() > } > > func (d *Dog) Walks() { > > } > > func CheckWalker(w Walker) { > > } > > func main() { > dog := Dog{} > CheckWalker(dog) -

[go-nuts] Question regarding Golang Interfaces and composite struct

2022-04-28 Thread Glen D souza
Consider the following piece of code type Dog struct { } type Walker interface { Walks() } func (d *Dog) Walks() { } func CheckWalker(w Walker) { } func main() { dog := Dog{} CheckWalker(dog) -> cannot use dog (variable of type Dog) as Walker value in argument to CheckWalker: Do

Re: [go-nuts] question about the "database/sql" package.

2022-01-15 Thread 'Axel Wagner' via golang-nuts
There is an argument to be made that this allows code using `database/sql` to take the arguments to `Open` directly from an environment variable/config file and pass them on, to support multiple DBMS. But really, it would have probably been a better design to directly take the Driver, yes. However,

[go-nuts] question about the "database/sql" package.

2022-01-15 Thread sina safari
Hi, I have a question about the "database/sql" package. Why doesn't the "Open" function take the "driver.Driver" interface instead of the driver name? like this: func Open(driveri driver.Driver, dataSourceName string ) (*DB ,

Re: [go-nuts] question about stdin

2021-12-12 Thread Jan Mercl
On Sun, Dec 12, 2021 at 5:15 PM Денис Мухортов wrote: > It's a little unclear how os.stdin actually works. Why, if you just run the > program, is data from stdin constantly being listened to? > For example: > func main() { > sc := bufio.NewScanner(os.Stdin) > for sc.Scan() { > tx

Re: [go-nuts] question about stdin

2021-12-12 Thread 'Axel Wagner' via golang-nuts
os.Stdin is whatever the file descriptor 0 is being connected to by the OS. Depending on the type of file descriptor, Read will behave differently. If you call a program on the command line, the shell connects it to its controlling terminal, which is usually line-buffered and a read from it will bl

[go-nuts] question about stdin

2021-12-12 Thread Денис Мухортов
It's a little unclear how os.stdin actually works. Why, if you just run the program, is data from stdin constantly being listened to? For example: func main() { sc := bufio.NewScanner(os.Stdin) for sc.Scan() { txt := sc.Text() fmt.Printf("echo: %s\n", txt) } } But if y

[go-nuts] question about httputil. NewSingleHostReverseProxy

2021-10-18 Thread Vasiliy Tolstov
Hi. I'm use go reverse proxy in some project and have a question https://cs.opensource.google/go/go/+/refs/tags/go1.17.2:src/net/http/httputil/reverseproxy.go;l=323 why headers when copied added to already written? Why copyHeader do Add method for header and not Set ? For example - I have middlewar

[go-nuts] question about Profiling Go Programs sample.

2021-09-27 Thread alex-coder
Hi All, currently I walk through sample given there: Profiling Go Programs - go.dev but when I came at the point where the user should enter web command to the pprof I do not see that the function DFS call itself on a picture. Looks like I do use a proper version of t

Re: [go-nuts] Question on handling Data Race

2021-09-12 Thread Martin Schnabel
hi Michael, from my understanding: if you only call refresh from somefunc and locking the body should be fine. however i strongly advise not to export refresh, otherwise it is a broken api. and someone, someday will call refresh without that lock. if refresh should be part of the accessible a

Re: [go-nuts] Question on handling Data Race

2021-09-11 Thread Kurtis Rader
On Sat, Sep 11, 2021 at 6:49 PM Michael Dwyer wrote: > Kurtis, > > I realized this question would arise. > Presently working with an existing code base. > The code presented in the example is a close approximation to what > actually exists, the only thing changed were the names. > Additionally, I

Re: [go-nuts] Question on handling Data Race

2021-09-11 Thread Michael Dwyer
Kurtis, I realized this question would arise. Presently working with an existing code base. The code presented in the example is a close approximation to what actually exists, the only thing changed were the names. Additionally, I checked the package and the call order is SomeFunc() -> Refresh()

Re: [go-nuts] Question on handling Data Race

2021-09-11 Thread Kurtis Rader
On Sat, Sep 11, 2021 at 5:01 PM Michael Dwyer wrote: > Presently working on a Data Race and have some questions on how to proceed. > The code example is a hypothetical mock up of the actual code under > review, but is a fair representation. > > The struct used by both functions is named Foo. > In

[go-nuts] Question on handling Data Race

2021-09-11 Thread Michael Dwyer
Presently working on a Data Race and have some questions on how to proceed. The code example is a hypothetical mock up of the actual code under review, but is a fair representation. The struct used by both functions is named Foo. In the hypothetical, SomeFunc() reads variable from foo.bar, checki

[go-nuts] Question about container/heap

2021-06-13 Thread Travis Keep
Recently I implemented a heap in GO. To implement a heap, you have to implement Push() and Pop() as well as the 3 methods for sort: Less(),, Swap(), and Len(). For my heap, I never had to Push or Pop, I only had to initialize the heap and repeatedly "Fix" the top element of the heap. As it tu

Re: [go-nuts] question about shot write barrier instructions

2021-05-10 Thread Ian Lance Taylor
On Mon, May 10, 2021 at 5:56 AM 计算鸡 wrote: > > ```go > package main > > type T struct { > a *int > } > > func test(t *T, b *int) { > t.a = b > } > ``` > compile this code use cmd `go build -gcflags '-l' main.go` > only disable inline stage . > > here is the plan9 assembly of functi

[go-nuts] question about shot write barrier instructions

2021-05-10 Thread 计算鸡
```go package main type T struct { a *int } func test(t *T, b *int) { t.a = b } ``` compile this code use cmd `go build -gcflags '-l' main.go` only disable inline stage . here is the plan9 assembly of function test ```assembly TEXT main.test(SB) src/write-barrier/main.go m

[go-nuts] Question on module versioning expected behavior

2021-03-23 Thread Marcin Romaszewicz
I recently hit a little issue with go.mod versioning that's confusing me. My go.mod is straightforward: https://github.com/deepmap/oapi-codegen/blob/master/go.mod One of the packages in there is kin-openapi at v0.47.0: github.com/getkin/kin-openapi v0.47.0 We briefly had some code in the repo whi

[go-nuts] Question about "go get", modules and indirect dependencies

2021-01-05 Thread Orson Cart
Apologies if this is a dumb question as I don't have a great deal of experience with modules. So, if I use the "go get" command to download a module, when I look in the module cache the @v directory of the requested module contains at least one .info file. This isn't the case for any indirect d

Re: [go-nuts] Question about blog post: https://blog.golang.org/pipelines

2020-12-01 Thread nc
Great, thanks for that clarification. On Tuesday, December 1, 2020 at 4:51:11 PM UTC-4 Jan Mercl wrote: > On Tue, Dec 1, 2020 at 9:05 PM nc wrote: > > I just wanted to know if there was a way to tell that the goroutines c1, > c2 actually are hung. Could I in my head add the sentences "While the

Re: [go-nuts] Question about blog post: https://blog.golang.org/pipelines

2020-12-01 Thread Jan Mercl
On Tue, Dec 1, 2020 at 9:05 PM nc wrote: > I just wanted to know if there was a way to tell that the goroutines c1, c2 > actually are hung. Could I in my head add the sentences "While the program > terminates, that is only because the main goroutine has finished its > execution. One of the send

[go-nuts] Question about blog post: https://blog.golang.org/pipelines

2020-12-01 Thread nc
Hello, This is my first time on this mailing list. I'm trying to learn about Go concurrency patterns. I am looking at the Stopping Short section and in particular at the following code: https://blog.golang.org/pipelines#TOC_5.:~:text=%2F%2F%20Consume%20the%20first%20value%20from%20the,%7D I t

Re: [go-nuts] Question on the generics proposal and arrays

2020-10-07 Thread Markus Heukelom
On Wed, Oct 7, 2020 at 9:12 PM Howard C. Shaw III wrote: > You said: > >> I was trying around with arrays and generics because slices are more >> complex to reason about than arrays. For example, I introduced bugs into my >> code by not being fully aware of slices overwriting original data when y

Re: [go-nuts] Question on the generics proposal and arrays

2020-10-07 Thread Howard C. Shaw III
You said: > I was trying around with arrays and generics because slices are more > complex to reason about than arrays. For example, I introduced bugs into my > code by not being fully aware of slices overwriting original data when you > append to them and the capacity is not set correctly. So

Fwd: [go-nuts] Question on the generics proposal and arrays

2020-10-07 Thread Markus Heukelom
On Tue, Oct 6, 2020 at 7:45 PM Ian Lance Taylor wrote: > On Tue, Oct 6, 2020 at 6:32 AM Markus Heukelom > wrote: > > > > It appears to me the current proposal does not allow you to write a > function that sorts an array of any size: > > > > func SortArray[T comparable](array [??]T, less func(a,

Re: [go-nuts] Question on the generics proposal and arrays

2020-10-06 Thread Ian Lance Taylor
On Tue, Oct 6, 2020 at 6:32 AM Markus Heukelom wrote: > > It appears to me the current proposal does not allow you to write a function > that sorts an array of any size: > > func SortArray[T comparable](array [??]T, less func(a, b T) bool) [??]T {} > > Is it correct that this is not possible? Or

[go-nuts] Question on the generics proposal and arrays

2020-10-06 Thread Markus Heukelom
It appears to me the current proposal does not allow you to write a function that sorts an array of any size: func SortArray[T comparable](array [??]T, less func(a, b T) bool) [??]T {} Is it correct that this is not possible? Or is this expressed differently? To clarify, I am seeking for someth

[go-nuts] Question on gofmt and go vet and field tag keys

2020-07-23 Thread Markus Heukelom
Is there a way to instruct gofmt (or another tool) to reformat field tags such that the keys are aligned? For example: type Example struct { Field1 string `json:"x" db:"y"` Field2 int `json:"ababababc" db:"def"` Field3 string `json:"zyx" db:"egh"` Field4 string `json:"z" db:"q"` } Would be for

Re: [go-nuts] Question about safe unsafe.Pointer conversion rules

2020-06-19 Thread Ian Lance Taylor
On Fri, Jun 19, 2020 at 12:04 PM Iskander Sharipov wrote: > > https://golang.org/src/runtime/symtab.go?s=7594:7745#L244 > > type Func struct { > > opaque struct{} // unexported field to disallow conversions > > } > > > func (f *Func) raw() *_func { > > return (*_func)(unsafe.Pointe

[go-nuts] Question about safe unsafe.Pointer conversion rules

2020-06-19 Thread Iskander Sharipov
Hello! https://golang.org/src/runtime/symtab.go?s=7594:7745#L244 type Func struct { opaque struct{} // unexported field to disallow conversions } func (f *Func) raw() *_func { return (*_func)(unsafe.Pointer(f)) } An empty struct Func (T1) is converted to a non-zero struct

Re: [go-nuts] Question about strings.EqualFold vs Python's casefold

2020-04-30 Thread Miki Tebeka
Thanks! On Friday, May 1, 2020 at 8:21:48 AM UTC+3, Ian Lance Taylor wrote: > > On Thu, Apr 30, 2020 at 9:42 PM Miki Tebeka > wrote: > > > > I'm trying to find an example where strings.EqualFold returns true but > comparison of strings.ToLower fails. > > I've found this example (in Python):

Re: [go-nuts] Question about strings.EqualFold vs Python's casefold

2020-04-30 Thread Ian Lance Taylor
On Thu, Apr 30, 2020 at 9:42 PM Miki Tebeka wrote: > > I'm trying to find an example where strings.EqualFold returns true but > comparison of strings.ToLower fails. > I've found this example (in Python): > > s1 = "der Fluß" > s2 = "der Fluss" > > print('lower', s1.lower() == s2.lower()) > print('

[go-nuts] Question about strings.EqualFold vs Python's casefold

2020-04-30 Thread Miki Tebeka
Hi, I'm trying to find an example where strings.EqualFold returns true but comparison of strings.ToLower fails. I've found this example (in Python): s1 = "der Fluß" s2 = "der Fluss" print('lower', s1.lower() == s2.lower())

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-19 Thread Brian Candler
I just don't like the implication that these things *haven't* been thought about, because nobody could be bothered to polish the "rough edges". -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving ema

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-19 Thread Michel Levieux
Though I think I *do* agree with you on that particular point (zero-value design), I'd say this argument is rarely a real one. Let me explain myself: However clever Google's thousands of programmers are, there might be places for improvement and I personally want people to try and propose evolution

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-19 Thread Brian Candler
On Wednesday, 19 February 2020 10:59:33 UTC, klos...@gmail.com wrote: > > I see in a programming language as my most important tool. I use it every > single day to make a living. It is because of that importance that I want > me (and my team) to be as efficient as possible when working with it, s

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-19 Thread Volker Dobler
On Wednesday, 19 February 2020 11:59:33 UTC+1, klos...@gmail.com wrote: > > [...] > But if you create wood houses for people, you don't even think of using a > hammer! You will use a much more reliable tool. Or if you use it, it will > probably be the best hammer in the market, with a perfect wei

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-19 Thread kloster08
Thanks a lot for your response. All your points make sense and I can understand your point of view. I simply have a slightly different point of view that my experience has shaped. I see in a programming language as my most important tool. I use it every single day to make a living. It is becaus

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-18 Thread Jake Montgomery
> > The problem with that reasoning is that you could use it for anything and > then we would never improve any programming language or create others. > Ideally, the compiler will catch all the bugs it possibly can so that the > programmer can spend the thinking energy on resolving the problem.

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-18 Thread Robert Engels
.-Original Message- From: kloste...@gmail.com Sent: Feb 18, 2020 9:55 AM To: golang-nuts Subject: Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to? I'd say that's not solving the problem, but making it bigg

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-18 Thread kloster08
> > I'd say that's not solving the problem, but making it bigger. Do not > recover from nil panics, instead fix the nil dereference bug and avoid > the panic completely. > It is never that easy in a medium to big application with a 10+ people team working on it. The problem with that reasoni

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-18 Thread Jesper Louis Andersen
On Tue, Feb 18, 2020 at 1:22 PM Jan Mercl <0xj...@gmail.com> wrote: > > The CPU does not care how humans call the abstraction. It has still to > do the same old thing: check some value for being equal/not equal to a > sentinel value or check a tag value for the same effect. That means > additional

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-18 Thread Jesper Louis Andersen
If you have type 'a option = None | Some 'a you have a so-called "lift" where "None" is a new value playing the role as no-information or "null". This allows you use the full range of 'a whatever that is, because you glued a new null-value to it. However, the problem you may face is that a lot

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-18 Thread Jan Mercl
On Tue, Feb 18, 2020 at 12:44 PM wrote: > Well, other languages use the optional/maybe type. The CPU does not care how humans call the abstraction. It has still to do the same old thing: check some value for being equal/not equal to a sentinel value or check a tag value for the same effect. That

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-18 Thread Jesper Louis Andersen
On Mon, Feb 17, 2020 at 10:11 PM Rick Hudson wrote: > > type Treenode struct { > > left *Treenode > > right *Treenode > > } > > One could of course design a language where Treenode is called cons and > left is called car and right is called cdr and (car nil) is nil and (cdr > nil) is nil. You c

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-18 Thread Volker Dobler
On Tuesday, 18 February 2020 12:44:16 UTC+1, klos...@gmail.com wrote: > > Well, other languages use the optional/maybe type. It handles sentinel > values pretty well and I don't think they bring new kind of bugs (while > they remove the nil-pointer related bugs). > That is the market claim. And

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-18 Thread kloster08
Well, other languages use the optional/maybe type. It handles sentinel values pretty well and I don't think they bring new kind of bugs (while they remove the nil-pointer related bugs). It is true that they can be a bit cumbersome to use and maybe we lose what you said: *"the nice and cheap HW

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-18 Thread Jan Mercl
On Tue, Feb 18, 2020 at 12:09 PM wrote: > > Regarding pointers: For me, point number 2 (and 3) is the key that forces us > having some way of expressing emptiness in a pointer. I'd say that nil pointers are not really special. It's just a sentinel value. And we definitely need some sentinel valu

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-18 Thread kloster08
Thanks for the example, it is a really good one. At least for me, it is the first one where I see the real usefulness. I don't know why, but eventually, I was able to see the parallelism between maps and slices. All the confusion comes because we have "append" for slices and not for maps (becau

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-18 Thread kloster08
Regarding pointers: For me, point number 2 (and 3) is the key that forces us having some way of expressing emptiness in a pointer. I would say that point 1 could be optimized by the compiler Regarding interfaces: Yep! nil-interfaces are a different beast. That's the reason I focused on just one

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-17 Thread Rick Hudson
> type Treenode struct { > left *Treenode > right *Treenode > } One could of course design a language where Treenode is called cons and left is called car and right is called cdr and (car nil) is nil and (cdr nil) is nil. You could implement such a language by putting 2 words of 0 at location

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-17 Thread Brian Candler
That's a very good point: * A map can contain any type of value * map[value_not_present] is defined to return the zero value * If the map contains other maps: (a) you don't want a new map to spring into life every time you access a non-existent key - especially not a floating map which isn't stor

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-17 Thread Levieux Michel
@Sam, hi, yes, that was the point ^^ My example was here to say "ok, so let's say the first case works because we have made uninitialized maps work, but how do we handle the second case?" It was not made to be runnable as is, I just wanted it to be readable :) Sorry if that was not clear Le lun.

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-17 Thread Sam Whited
I think you need to run your example; the behavior is the same: trying to make an assignment to the non-nested map will panic contrary to what your comment says. > panic: assignment to entry in nil map —Sam On Mon, Feb 17, 2020, at 10:35, Michel Levieux wrote: > Hi Kloster08, > > In addition to

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-17 Thread Michel Levieux
Hi Kloster08, In addition to what others have already pointed out, I'd like to bring you another case that seems problematic to me concerning the construction of a "usable nil value" for maps, in the sense that a zero-value map could be written and read right away without any initialization. Here

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-17 Thread 'Axel Wagner' via golang-nuts
On Mon, Feb 17, 2020 at 11:18 AM wrote: > Out of curiosity: Could you please tell when calling methods on nil > pointers is useful? > In general, linked datastructures - like linked lists or trees. As a somewhat trivial example, consider this: https://play.golang.org/p/Y-4aSVLzEFO Interpreting a

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-17 Thread Brian Candler
A "usable" nil map, i.e. being able to insert into it straight away, I sympathise with. Remember though that you can't append "in place" to a nil slice: it returns a new slice object. https://play.golang.org/p/dL-r74C5m_w I presume you don't want to write the same for maps as you do for slices

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-17 Thread kloster08
Nil slices are an example of an ideal zero value. When you use them, you don't need to check for nil -> its zero value is already usable. Exactly the "slices" case (and the "string" type) is the one inspiring me to search for more useful zero values for certain types. The two I am thinking more

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-17 Thread kloster08
I thought of this at the beginning, but when I tried to make it work I realized that I needed to have the following if: if s != nil { /* initialize struct or inform it is nil */ } on every struct method, which eventually defeated the purpose for my use case. Out of curiosity: Could you ple

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-15 Thread Jake Montgomery
> > I see it is a nice property, but I'd say only for people writing the > compiler. I adventure [sic] to say that people using the language won't > care too much about this property. Having a useful zero-value (in this > case, an initialized pointer), like we have with strings for example, >

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-15 Thread Tristan Colgate
It's also worth pointing out that a nil pointer value can still be useful. You can still call methods on it. On Sat, 15 Feb 2020, 13:13 , wrote: > Woah! that's a killer reason, the one I was searching for. Thanks for > pointing it out, as you have saved me a lot of time discarding the proposal >

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-15 Thread kloster08
Woah! that's a killer reason, the one I was searching for. Thanks for pointing it out, as you have saved me a lot of time discarding the proposal I had in mind. I will need to go in other direction. El viernes, 14 de febrero de 2020, 15:52:07 (UTC), Brian Candler escribió: > > In addition, cons

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-15 Thread kloster08
Thanks for the response! and the pointer itself would lose the nice property of being a zeroed chunk > of memory (it wouldn't be a zero value). > I see it is a nice property, but I'd say only for people writing the compiler. I adventure to say that people using the language won't care too much

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-14 Thread Brian Candler
In addition, consider: how would you implement the zero default when the type is self-referential? For example: type Treenode struct { left *Treenode right *Treenode } var Tree1, Tree2 *Treenode Also consider deeply nested types which include pointers to structs which contain pointers etc

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-14 Thread Sam Whited
On Fri, Feb 14, 2020, at 09:16, kloste...@gmail.com wrote: > *Could you please let me know the reasons why the zero value of a > pointer is `nil` instead of a pointer to the zero value of what it > points to?* > > Is it because of performance/memory? Simplicity in the runtime? The zero value is a

[go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-14 Thread kloster08
This is a question to get some information before thinking about a possible proposal regarding zero values. *Could you please let me know the reasons why the zero value of a pointer is `nil` instead of a pointer to the zero value of what it points to?* Is it because of performance/memory? Simpl

Re: [go-nuts] Question about 'import' statement

2020-02-03 Thread Ian Lance Taylor
On Mon, Feb 3, 2020 at 11:40 AM joe mcguckin wrote: > > Do all the files listed in the 'import' statement get pulled in and compiled, > or merely scanned to resolve function references etc. > > As someone who grew up on 'C', it seems a bit weird to not have an 'include' > mechanism and its heade

Re: [go-nuts] Question about 'import' statement

2020-02-03 Thread Brian Candler
Also, I believe "go fmt" sorts the imports. -- 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 t

Re: [go-nuts] Question about 'import' statement

2020-02-03 Thread Marcin Romaszewicz
All the files get downloaded to your $GOPATH/src or $GOPATH/pkg, depending on whether modules are enabled. Everything gets compiled together into the same static executable, so yes, the files get compiled. The order of imports should not matter in well written code, but you can always create scen

[go-nuts] Question about 'import' statement

2020-02-03 Thread joe mcguckin
Do all the files listed in the 'import' statement get pulled in and compiled, or merely scanned to resolve function references etc. As someone who grew up on 'C', it seems a bit weird to not have an 'include' mechanism and its headers. Does the it matter what order the files appear in the impor

[go-nuts] Question regarding a very tricky build set up

2019-12-22 Thread christophberger . com
Oh my gosh. You could have saved all the time for writing that long long question if someone had told you before that GOPATH is a thing of the past. Go has a new package dependency management system called Go Modules, and this removes the need for a central source code workspace. See https://

[go-nuts] Question regarding a very tricky build set up

2019-12-21 Thread kevmarschke
Let me explain my situation. I'm making a website and uses some very advanced functionality. It includes a front-end wasm module, a daemon (written in GoLang), nginx configuration, some PHP, and some haml, and sass. I have written a makefile to build everything into 1) ELF binary (the daemon),

[go-nuts] question about 'go vet ' with flag specifying 'analyzer'

2019-11-20 Thread Xiangdong JI
Hi, When I run 'go vet' on specific package with the 'analyzer' flag, its behavior seems to depend on where the command is invoked, can anyone please shed a light here, any code pointers that may help me understand the difference is highly appreciated. 1. under /src, -unreachable=false suppres

[go-nuts] Question: package rename

2019-11-13 Thread awh6al
Hi gophers, i have a question about renaming a package like `debug/plan9obj` to `p9` with a required changes in the package files. I got a `can't load package` message from `go test -v debug/p9` command, any ideas? -- You received this message because you are subscribed to the Google Groups "

Re: [go-nuts] question about runtime design

2019-10-14 Thread Ian Lance Taylor
On Mon, Oct 14, 2019 at 5:53 AM wrote: > > salam. Hi gophers can any one take a look at at this snippet of code > https://play.golang.org/p/qv0N0EN81tX > and answer me why should this panic at runtime, and why the compiler > does not catch this kind of mistakes. I assume that you are asking why i

[go-nuts] question about runtime design

2019-10-14 Thread awh6al
salam. Hi gophers can any one take a look at at this snippet of code https://play.golang.org/p/qv0N0EN81tX and answer me why should this panic at runtime, and why the compiler does not catch this kind of mistakes. -- You received this message because you are subscribed to the Google Groups "g

Re: [go-nuts] Question re fcns that return multiple values

2019-08-05 Thread Adrian Ho
On 6/8/19 11:38 AM, lgod...@gmail.com wrote: > For f1 defined as func f1(k1, k2, k3 int) (x1, x2 int) {..}  > and f2 defined as func f2(x,y int)           (xR int)       {..}  > > Why does the compiler complain about the call stmt  > f2 ( f1 (1,2,3)  )   ?? > It shouldn't. What little you posted is

Re: [go-nuts] Question re fcns that return multiple values

2019-08-05 Thread Jesse McNelis
On Tue, Aug 6, 2019 at 1:38 PM wrote: > For f1 defined as func f1(k1, k2, k3 int) (x1, x2 int) {..} > and f2 defined as func f2(x,y int) (xR int) {..} > > Why does the compiler complain about the call stmt > f2 ( f1 (1,2,3) ) ?? > I'm not sure what you're asking. The compiler

[go-nuts] Question re fcns that return multiple values

2019-08-05 Thread lgodio2
For f1 defined as func f1(k1, k2, k3 int) (x1, x2 int) {..} and f2 defined as func f2(x,y int) (xR int) {..} Why does the compiler complain about the call stmt f2 ( f1 (1,2,3) ) ?? -- You received this message because you are subscribed to the Google Groups "golang-nuts" g

  1   2   3   >