Toolchains in Go
This is a blog for Go toolchains, I will try to explain what is toolchain, how to use it and why Go needs it.
');--md-admonition-icon--abstract:url('data:image/svg+xml;charset=utf-8,');--md-admonition-icon--info:url('data:image/svg+xml;charset=utf-8,');--md-admonition-icon--tip:url('data:image/svg+xml;charset=utf-8,');--md-admonition-icon--success:url('data:image/svg+xml;charset=utf-8,');--md-admonition-icon--question:url('data:image/svg+xml;charset=utf-8,');--md-admonition-icon--warning:url('data:image/svg+xml;charset=utf-8,');--md-admonition-icon--failure:url('data:image/svg+xml;charset=utf-8,');--md-admonition-icon--danger:url('data:image/svg+xml;charset=utf-8,');--md-admonition-icon--bug:url('data:image/svg+xml;charset=utf-8,');--md-admonition-icon--example:url('data:image/svg+xml;charset=utf-8,');--md-admonition-icon--quote:url('data:image/svg+xml;charset=utf-8,');}
This is a blog for Go toolchains, I will try to explain what is toolchain, how to use it and why Go needs it.
This blog try to introduce the go list
command and brief a refinement at go1.16
. Moreover, we will explore the differences between go list -m all
and go list all
, and answer question why some of the module from go list -m all
cannot be found by go mod why
.
Finally, we will see the x/mod
package and when it's useful.
Last time, when one of users asked me "could I set up a 100d
in his yaml file for Go time.Duration
", my first action is why he cannot search the documentation by himself. But then, another problem overwhelmed my mind because actually I'm not sure about it. I don't know it as well.
After seeing the source code, I got the answer. However, the important inspiration here is: "how to make knowledge cohesive", hence the blog comes. In short, you should understand several concepts here:
By enquiring these questions progressively, you can easily recognize how yaml works in a cohesive way instead of remembering some scattered knowledge about it.
In the open source framework, as long as maintainers can ensure the issues are caused by users instead of the framework, usually they could provide some suggestive guides and prevent themselves from delving into users code.
However, as a company scope framework maintainer, things differ greatly. As you claimed your framework helps them to write better code based on the company platforms, they're likely to rely on the maintainers to figure out some weird issues once it's related with the framework.
This blog records how I help to trouble shoot the weird issue of keeping restarting and failed to deploying caused by the log.Fatalf
for our framework users, and my opinion why the log.Fatalf
is bad.
This blog records the tricky part of using reflect
to get an empty interface type correctly. The background is that a component requires the configuration type during function call as it might use the type to construct a type and set up the value based on some external data set. If we cannot find a respective in some scenarios, empty interface type should be passed.
However, at the beginning due to the wrong usage of reflect, a nil
type instead of interface{}
type is passed by reflect.TypeOf(i)
.
var i interface{}
// this is correct
typ := reflect.TypeOf(&i).Elem()
// this is wrong usage, the typ is nil
typ := reflect.TypeOf(i)