On Oct 19, 2023, at 9:02 PM, Nurahmadie Nurahmadie wrote:
>
> Is it not possible to have both _auto_ downcasting and new method binding to
> work in Go?
What you are suggesting may make things more *convenient* but
at the same time the potential for accidental mistakes goes
up. The key is find
> Personally, I find "why" questions suspicious. They are usually thinly
> disguised requests to change the existing behavior. And that appears to be
> the case for this discussion.
>
No, that's not to be the case, I do imagining the change, but am not
thinking of requesting any change, I know th
On Thu, Oct 19, 2023 at 9:56 PM Nurahmadie Nurahmadie
wrote:
>
>> You have changed the question. You are no longer asking about defining
>> methods on a type derived from a primitive type. Non-aliased types are
>> deliberately distinct types that cannot be "auto downcast" or "auto
>> upcast". Arg
Hi,
https://pkg.go.dev/golang.org/x/tools/cmd/goimports
goimports -w ./
On Thu, Oct 19, 2023, 8:31 PM Pratik Tamgole
wrote:
> When I use packages, any packages in general, how does the import("fmt")
> line correct itself to include the used packages in the program? What tool
> is implemented h
On Fri, 2023-10-20 at 11:56 +0700, Nurahmadie Nurahmadie wrote:
> why is there no, type coercion, as you said, that allow the new type
> to be acknowledged as its underlying type? which will not be a
> question if otherwise Go has mechanism to allow methods to be
> attached to foreign types.
There
>
>
> You have changed the question. You are no longer asking about defining
> methods on a type derived from a primitive type. Non-aliased types are
> deliberately distinct types that cannot be "auto downcast" or "auto
> upcast". Arguably the biggest flaw of the C language was its automatic type
>
On Thu, Oct 19, 2023 at 9:03 PM Nurahmadie Nurahmadie
wrote:
> Adding methods to a primitive type, or more generally adding methods
>> to a type defined in a different package, would cause different
>> packages to behave differently depending on whether they see the
>> methods. That would be con
> Adding methods to a primitive type, or more generally adding methods
> to a type defined in a different package, would cause different
> packages to behave differently depending on whether they see the
> methods. That would be confusing. It would meant that type
> assertions would sometimes suc
When I use packages, any packages in general, how does the import("fmt")
line correct itself to include the used packages in the program? What tool
is implemented here, I want to put the same in my editor.
--
You received this message because you are subscribed to the Google Groups
"golang-nut
On Thu, Oct 19, 2023 at 6:18 PM Nurahmadie Nurahmadie
wrote:
>
> There are two ways to enable this, which are worth discussing further as of
> why Go decided to behave this way.
>
> To use type alias as mentioned before `type MatrixF64 = Matrix[float64]`,
> this is generally works but unfortunat
On Fri, 20 Oct 2023 at 07:51, Ian Lance Taylor wrote:
> On Thu, Oct 19, 2023 at 5:14 PM Jason E. Aten wrote:
> >
> > Analogous to
> >
> > type IntSlice []int
> >
> > func (p IntSlice) Len() int { return len(p) }
> > func (p IntSlice) Less(i, j int) bool { return p[i].val < p[j].val }
> > func (p
On Thu, Oct 19, 2023 at 5:14 PM Jason E. Aten wrote:
>
> Analogous to
>
> type IntSlice []int
>
> func (p IntSlice) Len() int { return len(p) }
> func (p IntSlice) Less(i, j int) bool { return p[i].val < p[j].val }
> func (p IntSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
>
> and then calling
Analogous to
type IntSlice []int
func (p IntSlice) Len() int { return len(p) }
func (p IntSlice) Less(i, j int) bool { return p[i].val < p[j].val }
func (p IntSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
and then calling sort.Sort() on an IntSlice, I figured I
could create a type that is a
Gin does this directly. There is nothing complicated it does. Something
like:
group := engine.Group("/service/v1")
group.GET("user/:id", handler)
And then in the handler:
id := c.Param("id")
And the rest is what ever is yours. "engine" is a gin engine and 'c' is a
gin context.
On Thu, Oct
stdlib only with upcoming 1.22 which isn't yet released, see
https://eli.thegreenplace.net/2023/better-http-server-routing-in-go-122/
gorilla mux is another 3rd party muxer with variable support
https://github.com/gorilla/mux
the "best" way using only stdlib mux is to parse the path and extract
I'm not sure what the best way is.
But I think you can refer to the existing solutions. For example gin, mux.
Link: https://github.com/gin-gonic/gin/blob/master/tree.go#L116
在2023年10月19日星期四 UTC+8 19:27:59 写道:
> Hi everyone. I'm building an api with net/http and I'm having trouble
> with url
Hi everyone. I'm building an api with net/http and I'm having trouble with
url variables. How can I get the url variables form the url in the REST way.
Example, if I have a url like "http:/localhost:3000/users/:id". I want to
get the user with the id given from the url. What is the best way to g
17 matches
Mail list logo