Re: [go-nuts] Having trouble installing golint

2018-10-17 Thread Jason Phillips
Why do you think the first command (at golang.org) failed? Looks like everything worked to me. On Wednesday, October 17, 2018 at 3:48:05 PM UTC-4, kalekold wrote: > > I've already tried that and the original command still fails. > > $ go get -u -v golang.org/x/lint/golint > Fetching https://golan

Re: [go-nuts] Re: select multiple expressions per case

2017-12-21 Thread Jason Phillips
With a multiple expression switch statement, the associated case is executed if any expression is equal to the switch expression. For a multiple expression select, would all channel expressions have to proceed for the associated case to execute? e.g. select { case x := <-c1, y := <-c2: //

Re: [go-nuts] Re: select multiple expressions per case

2017-12-21 Thread Jason Phillips
thing } Jason On Thursday, December 21, 2017 at 2:38:02 PM UTC-5, matthe...@gmail.com wrote: > > I would assume only one would send/receive out of the comma list for a > case to be executed. > > Matt > > On Thursday, December 21, 2017 at 12:32:22 PM UTC-6, Jason Phillips wrote:

Re: [go-nuts] Extending an existing type by embedding

2018-01-01 Thread Jason Phillips
html.NewTokenizer returns a pointer to a Tokenizer. So, you probably want to embed a pointer: type MyTokenizer struct { *html.Tokenizer } func NewMyTokenizer(i io.Reader) *MyTokenizer { z := html.NewTokenizer(i) return &MyTokenizer{z} } If for some reason your want/need the Tokenizer value

[go-nuts] Re: Dependency hierarchy in go

2020-02-07 Thread Jason Phillips
Replace only works for the top-level go.mod. From the proposal doc (link ): > Minimal version selection gives the top-level module in the build > additional control, allowing it to exclude specific module versions or >

[go-nuts] Re: How to import one field from package, etc

2020-09-23 Thread Jason Phillips
Did you try your own suggestion? It seems to work fine: https://play.golang.org/p/KVo5COKj2ii On Wednesday, September 23, 2020 at 1:46:05 PM UTC-4 al...@channelmeter.com wrote: > Using node.js, we might have this: > > const z = new Z(); > exports.z = z > > and then in another file we can import

Re: [go-nuts] Re: How to import one field from package, etc

2020-09-23 Thread Jason Phillips
he methods, it won't "just work" with new versions of > the library that gets imported, right? > > > On Wed, Sep 23, 2020 at 11:59 AM Jason Phillips > wrote: > >> Did you try your own suggestion? It seems to work fine: >> https://play.gola

[go-nuts] Re: Proper way of mocking interfaces in unit tests - the golang way

2020-10-02 Thread Jason Phillips
In the general case, all testify assertions are doing under the hood is call t.Errorf (see here ). If you're calling the "FailNow" set of functions that's followed by t.FailNow, which e

[go-nuts] Re: Why key.PublicKey.Equal(key.PublicKey) return false ?

2020-10-27 Thread Jason Phillips
The implementation of Equal() expects the PublicKey argument to be a pointer to an rsa.PublicKey. If you do the following it works: if !key.PublicKey.Equal(&key.PublicKey) { t.Fatal("key mismatch") } It should probably be documented as such. On Tuesday, October 27, 2020 at 12:01:53 PM UTC-4

Re: [go-nuts] Go 1.18. Type Constraints are (not) interfaces!?

2021-12-15 Thread Jason Phillips
@Leonard, type constraints can only be used as type parameters, using them as normal interfaces is currently not allowed. See the notes in the draft release notes[1] or the draft 1.18 spec[2]. > Such interfaces may only be used as type constraints. > Interfaces that contain non-interface types,

Re: [go-nuts] Go 1.18. Type Constraints are (not) interfaces!?

2021-12-15 Thread Jason Phillips
As to _why_ this is the case, the generics proposal has a section about that: https://go.googlesource.com/proposal/+/refs/heads/master/design/43651-type-parameters.md#permitting-constraints-as-ordinary-interface-types On Wednesday, December 15, 2021 at 11:05:36 AM UTC-5 Jason Phillips wrote

[go-nuts] Re: An mistake in tip spec?

2022-01-06 Thread Jason Phillips
@Brian > interface{ int; m() } // *[specific type]* int (but type set is empty because int has no method m) > interface{ int; any } // no specific types (intersection is empty) *[even though the type set is not empty]* As noted in the first paragraph of the spec, the set of specific types is c

[go-nuts] Re: An mistake in tip spec?

2022-01-06 Thread Jason Phillips
And by "first paragraph of the spec" I mean "first paragraph of the Structure of interfaces section of the spec". Apologies. On Thursday, January 6, 2022 at 11:11:45 AM UTC-5 Jason Phillips wrote: > @Brian > > > interface{ int; m() } // *[specific type]* int (

[go-nuts] Re: An mistake in tip spec?

2022-01-06 Thread Jason Phillips
ot;. On Thursday, January 6, 2022 at 11:34:02 AM UTC-5 Jason Phillips wrote: > And by "first paragraph of the spec" I mean "first paragraph of the > Structure of interfaces section of the spec". Apologies. > > On Thursday, January 6, 2022 at 11:11:45 AM UTC-5 Jason

[go-nuts] Re: An mistake in tip spec?

2022-01-06 Thread Jason Phillips
> But the set of specific types is "int". But the *type set* is "int"... On Thursday, January 6, 2022 at 11:57:59 AM UTC-5 Jason Phillips wrote: > I take my argument back, I agree with Brian here. According to the spec > "interface{}" is a type element

[go-nuts] Re: An mistake in tip spec?

2022-01-06 Thread Jason Phillips
It does seem like the spec could be more clear for this specific example. The type set of "interface{ int; m() }" is called out explicitly so the same seems helpful for "interface{ int; any }". On Thursday, January 6, 2022 at 12:00:47 PM UTC-5 Jason Phillips wrote: > &g

[go-nuts] Re: Why you can name variable or type parameter int or uint8???

2022-02-11 Thread Jason Phillips
In C and C++[1][2] "int" and "float" are reserved keywords and thus can't be used as identifiers. In Go[3], "int" and "float64" are "predeclared identifiers"[4] and can be redefined, just like any other identifier. [1] - https://en.cppreference.com/w/c/keyword [2] - https://en.cppreference.com/w

[go-nuts] Re: Acessing struct field in generic

2022-02-21 Thread Jason Phillips
This is https://github.com/golang/go/issues/48522 which is described in the original proposal document but was deemed inessential for the implementation in 1.18. This will likely come in a later release. On Monday, February 21, 2022 at 7:13:24 AM UTC-5 Brian Candler wrote: > Just to add an obse

[go-nuts] Re: Constraining a type parameter to implement an interface via pointer receiver

2022-03-29 Thread Jason Phillips
Note that the linked code operates on a copy of each DoImpl so mutations won't be visible outside of DoSlice(): https://go.dev/play/p/sgRDQMcLow8 You can fix that by indexing into the slice instead: https://go.dev/play/p/0eA_pQ12jzl On Monday, March 28, 2022 at 5:11:47 PM UTC-4 s...@panix.com w

[go-nuts] Re: Array type parameters?

2022-06-05 Thread Jason Phillips
Not currently. See the "omissions" section of the proposal [1]: > No parameterization on non-type values such as constants. This arises most obviously for arrays, where it might sometimes be convenient to write type Matrix[n int] [n][n]float64. It might also sometimes be useful to specify signi

[go-nuts] Re: Invalid memory address of string object

2022-09-25 Thread Jason Phillips
Have your tried building and running your application with the race detector enabled[1]? You may have a data race. 1 - https://go.dev/doc/articles/race_detector On Sunday, September 25, 2022 at 2:16:23 PM UTC-4 Bernd Fix wrote: > Hi folks, > > I am using go1.19.1 for development and see a stran

[go-nuts] Re: golang.org/x/exp/jsonrpc2 bugs

2022-10-10 Thread Jason Phillips
Are these existing known bugs or did you open a ticket on the Go bug tracker? If there are already tickets for these known bugs, you should mention the ticket number in your code review. If there aren't tickets, you should probably start by opening a ticket and then linking to your changes. As

[go-nuts] Re: Unicode variable name error

2022-11-05 Thread Jason Phillips
Per the Go spec[1], an identifier consists of a Unicode letter followed by zero or more Unicode letters or digits. The character పే is in the Unicode category nonspacing mark rather than the category letter. If you choose a Telugu letter then your code compiles as expected[2]. [1] - https://go.

Re: [go-nuts] Error Interfaces

2022-11-06 Thread Jason Phillips
Also note that in your original example you created two unique pointers to your error type. Even if the errors created using errors.New were equal, your example would never return true. https://play.golang.com/p/A7SltVZTlvW On Sunday, November 6, 2022 at 12:43:26 AM UTC-4 nikhil...@gmail.com wr

[go-nuts] Re: Best practice for "main.go" to access members of a structure in the real package

2023-02-18 Thread Jason Phillips
There isn't a friend declaration but the Go tool does support a concept of "internal" packages since Go 1.4. Read about it here: https://go.dev/doc/go1.4#internalpackages On Saturday, February 18, 2023 at 12:18:03 AM UTC-5 Pat Farrell wrote: > I'm still struggling with how to setup my access. >

[go-nuts] Re: There are many private methods with identical code in several different packages, which is clearly not elegant; But adding a public method that can be accessed by other packages (a propo

2023-04-04 Thread Jason Phillips
If you're trying to share code among related packages within a module but not external to the module, "internal" packages[1][2] are one common way to accomplish that. It's a convention that's enforced by the "go" command. This solution is used within the standard library and other official pack

[go-nuts] Re: how do I use go test for code that needs a flag defined in flag package

2023-05-06 Thread Jason Phillips
The testing package documentation mentions this case explicitly: https://pkg.go.dev/testing#hdr-Main In short, you can define a main function (called TestMain) for your test package and call flag.Parse from there. On Saturday, May 6, 2023 at 4:03:59 PM UTC-4 Robert Solomon wrote: > A related is

Re: [go-nuts] testing whether two maps are the same object

2023-07-18 Thread Jason Phillips
You can also use the reflect package rather than (directly) reaching for unsafe. The reflect.DeepEqual function does something along the lines of: https://go.dev/play/p/IVt0Z-mxugh On Tuesday, July 18, 2023 at 10:45:18 AM UTC-4 Jan Mercl wrote: > On Tue, Jul 18, 2023 at 4:35 PM Jochen Voss wro

[go-nuts] Re: testing whether two maps are the same object

2023-07-18 Thread Jason Phillips
reflect.Value.UnsafePointer() is probably not safer than using unsafe directly, assuming you're using unsafe in a way that doesn't break the rules. Reflect is doing effectively the same unsafe.Pointer conversion under the hood [1]. It's certainly easier on the eyes, in my opinion, though. [1]

[go-nuts] Re: testing whether two maps are the same object

2023-07-18 Thread Jason Phillips
for. On Tuesday, July 18, 2023 at 11:44:53 AM UTC-4 Jason Phillips wrote: > reflect.Value.UnsafePointer() is probably not safer than using unsafe > directly, assuming you're using unsafe in a way that doesn't break the > rules. Reflect is doing effectively the same unsafe.Point

Re: [go-nuts] Re: Amateur's questions about "Go lang spec"

2023-07-28 Thread Jason Phillips
The confusion may come from the fact that a list of forbidden built-in operations is immediately followed by a list of (mostly) allowed operations that illustrate the original rule? With the exception of "len", it may be more clear for it to be structure like: ExpressionStmt = Expression

[go-nuts] Re: [rfc] build bug in type abstraction?

2023-08-16 Thread Jason Phillips
A few things: * As illustrated by the output in your README, it appears your "make list" command is only compiling "main/main.go", rather than both "main/main.go" and "main/run.go" * There can only be one main function per main package in Go, so I'm not sure how main/run.go and main/main.go are

Re: [go-nuts] keyword= support for function calls

2023-08-17 Thread Jason Phillips
Even if we assume that the addition of keyword arguments would be a positive for the Go language and ecosystem, it wouldn't be a backward compatible change to add a keyword argument unless we make additional changes to the language to support implicit conversions between function-with-keyword t

[go-nuts] Re: Is there a race in exec.CombinedOutput?

2023-10-03 Thread Jason Phillips
>From the Stdout/Stderr field documentation on the os/exec.Cmd type : "If Stdout and Stderr are the same writer, and have a type that can be compared with ==, at most one goroutine at a time will call Write." On Tuesday, October 3, 2023 at 9:55:16 PM UTC-4 王富民awa

[go-nuts] Re: go list fails, how do I clear "-mod=readonly"

2023-10-16 Thread Jason Phillips
I believe the fixes have already been released. Go 1.21 was released in August and there have been 5 point releases to 1.20 since your version (1.20.5) was released. Have you tried updating your Go toolchain? On Monday, October 16, 2023 at 4:21:11 PM UTC-4 Pat Farrell wrote: > yes that is it. >

[go-nuts] Re: How to develop with Go source code change?

2024-01-04 Thread Jason Phillips
Note that just because there was a unit test failure doesn't mean the Go toolchain you built is not working. all.bash runs make.bash followed by run.bash. If I remember correctly, and if things haven't changed drastically since the last time I did it, the only required step for a usable toolcha

Re: [go-nuts] Re: Good examples of Go back ends?

2024-01-22 Thread Jason Phillips
Much of the code backing the official Go website and infrastructure is open source and hosted (or at least mirrored into) the golang Github project at https://github.com/golang Some specific examples: - pkgsite, the backend for pkg.go.dev: https://github.com/golang/pkgsite - vulndb, the b

Re: [go-nuts] Re: Is encoding/json POSIX compatible?

2024-01-30 Thread Jason Phillips
More generally, the input and output of encoding/json need not be a file at all. On Tuesday, January 30, 2024 at 10:54:57 AM UTC-5 Brian Candler wrote: > By the definition of "3.403 Text File > " > > then no,

[go-nuts] Re: Error on installing package

2024-02-06 Thread Jason Phillips
There's no Go package at the root of that repo/module, and thus nothing to install. "go install" only works on main packages. On Tuesday, February 6, 2024 at 8:34:07 AM UTC-5 Smit K wrote: > With this command: go install 154.pages.dev/goo...@v1.4.0 > > It is

[go-nuts] Re: Error on installing package

2024-02-06 Thread Jason Phillips
Perhaps you wanted "go get 154.pages.dev/google@v1.4.0"? On Tuesday, February 6, 2024 at 11:36:11 AM UTC-5 Jason Phillips wrote: > There's no Go package at the root of that repo/module, and thus nothing to > install. "go install" only works on main packages. >

[go-nuts] Re: Error on installing package

2024-02-07 Thread Jason Phillips
ay, February 7, 2024 at 9:13:22 AM UTC-5 Smit K wrote: > How to use this 154.pages.dev/goo...@v1.4.0 > <http://154.pages.dev/google@v1.4.0> > > On Tuesday, February 6, 2024 at 10:07:24 PM UTC+5:30 Jason Phillips wrote: > >> Perhaps you wanted "go get 154.pages.

[go-nuts] Re: 1.22.0 ServeMux HandleFunc infinite loop

2024-02-08 Thread Jason Phillips
Can you create a small self-contained program that reproduces the issue? The following program returns 404 locally, as I'd expect, but does get killed in the Go playground: https://go.dev/play/p/FigBLK8KrAK Perhaps there's an issue with the Playground networking implementation that's incompatib

Re: [go-nuts] Why can't I use an interface which needs another interface inside of it

2024-03-13 Thread Jason Phillips
Regardless, that's the reason what you've attempted doesn't work. It has its own entry in the Go FAQ: https://go.dev/doc/faq#covariant_types On Wednesday, March 13, 2024 at 1:00:34 PM UTC-4 Rodrigo Araujo wrote: > 'Cause this dependency makes code more "rigid". A refactor in an isolated > pack

[go-nuts] Re: pkg.go.dev: redirect URL for latest major version or big red warning for old version

2024-04-08 Thread Jason Phillips
If a major version is truly obsolete the maintainers can deprecate it. In which case the pkg.go.dev UI stands out a bit more. Take for example: github.com/golang/protobuf/proto . On Monday, April 8, 2024 at 2:12:54 PM UTC-4 twp...@gmail.com w

Re: [go-nuts] Re: pkg.go.dev: redirect URL for latest major version or big red warning for old version

2024-04-08 Thread Jason Phillips
er, there are is no deprecation message for > github.com/google/go-github: > > https://github.com/google/go-github/blob/b603120bf932e99e8cc0a9fab0693fa6b5f92c4d/go.mod > > Is there any way for google/go-github add a deprecation message for their > v0/v1/.../v60 major versio

[go-nuts] Re: go mod conflict whith v2 pre-release

2024-04-17 Thread Jason Phillips
I believe the hosting provider is returning a meta tag for "go.xrfang.cn/hap/v2" when it shouldn't? > curl https://go.xrfang.cn/hap/v2?go-get=1 https://e.coding.net/xrfang/go/hap.git";> The above meta tag says that the "go.xrfang.cn/hap/v2" module is at the root of the repository, but it'

Re: [go-nuts] Re: go mod conflict whith v2 pre-release

2024-04-17 Thread Jason Phillips
<http://go.xrfang.cn/hap/v2@v2.0.0-alpha.2/go.mod>: reading > https://sum.golang.org/lookup/go.xrfang.cn/hap/v...@v2.0.0-alpha.2 > <https://sum.golang.org/lookup/go.xrfang.cn/hap/v2@v2.0.0-alpha.2>: 404 > Not Found > server response: > not found: go.xrfang.cn/hap/v...@v2.0

Re: [go-nuts] Re: go mod conflict whith v2 pre-release

2024-04-18 Thread Jason Phillips
y, but this feels like it could >> get confusing (for the wetware - i.e. humans - if not the tooling). >> >> >> This is a genuine question, not intended to criticise the approach but to >> understand it as - if "official" - it's something I did not come

Re: [go-nuts] encoding/asn1 I can't Marshal a struct with pointer members

2024-04-29 Thread Jason Phillips
Then that type probably won't work with encoding/asn1. If you have control over the call to asn1.Marshal, you could always create a "data transfer object " to translate between this third-party type and a type that you control that has a struc

Re: [go-nuts] Importing non-module based code

2024-07-16 Thread Jason Phillips
You don't mention what version of Go you're using but, note from the Go 1.22 release notes: > go get is no longer supported outside of a module in the legacy GOPATH mode (that is, with GO111MODULE=off). Other build commands, such as go build and go test, will continue to work indefinitely for l

Re: [go-nuts] go test cache: include umask as a test input for caching?

2024-09-16 Thread Jason Phillips
Why can't it be set within subtests? Note that subtests (like regular tests) aren't run in parallel unless you explicitly call t.Parallel(). On Friday, September 13, 2024 at 6:35:15 PM UTC-4 twp...@gmail.com wrote: > > Personally, I would approach this kind of thing by writing a test that > sets

Re: [go-nuts] Can not convert a generic struct type to a generic interface type in golang

2024-10-28 Thread Jason Phillips
The Go FAQ has another, perhaps slightly more applicable, entry: https://go.dev/doc/faq#t_and_equal_interface Basically, even though *packet satisfies the Packet interface, interface { Get() *packet } Is different than interface { Get() Packet } And one isn't d

Re: [go-nuts] Can not convert a generic struct type to a generic interface type in golang

2024-10-28 Thread Jason Phillips
And by "interface signatures" I of course meant method signatures in the corresponding interface method sets. On Monday, October 28, 2024 at 4:39:35 PM UTC-4 Jason Phillips wrote: > The Go FAQ has another, perhaps slightly more applicable, entry: > > https://go.dev/doc/faq#t_

Re: [go-nuts] Is it necessary to change the behavior of maps.Keys and maps.Values?

2024-12-24 Thread Jason Phillips
Both maps.Keys and maps.Values exist in the standard library, https://pkg.go.dev/maps#Keys Perhaps I'm missing some nuance about the difference between x/exp/maps and the standard library implementation? On Tuesday, December 24, 2024 at 2:31:04 AM UTC-5 Sebastien Binet wrote: > Hi, > > If you

[go-nuts] Re: Race in table driven tests with httptest server

2025-01-31 Thread Jason Phillips
It's not clear from your example why you're writing to the "response" variable in the first place. One simple solution would be to create the test server within the subtest, then there's no sharing at all. There are only a few ways to fix a data race and they don't really depend on the specific

[go-nuts] Re: Running "go mod tidy" automatically changes "go 1.23" to "go 1.23.0"

2025-01-15 Thread Jason Phillips
Since Go 1.21, the go directive in go.mod must be greater than or equal to the go directive for all dependencies. Almost certainly, in the first case there's a dependency that specifies 1.23.0 and in the second case all dependencies are 1.23 or older. Jason On Wednesday, January 15, 2025 at 1