-
Notifications
You must be signed in to change notification settings - Fork 0
Learn Go
DUONG Phu-Hiep edited this page Apr 30, 2024
·
6 revisions
https://uber-go.github.io/fx/get-started/
- Question: objects life cycle (scoped, singleton..)?
- Read/Write nil channel blocked forever
- Read a closed channel returns 0 (immediately)
- Write to a closed channel panic
- nil channel will never be selected (
select case
statement) - a closed channel, will be selected immediately, and get nil value of the channel type. Thus may cause the other channels in the select never get selected.
https://github.com/sourcegraph/conc
type SomeInterface interface {
Method()
}
type Implementation struct{}
func (*Implementation) Method() { fmt.Println("Hello, World!") }
var _ SomeInterface = (*Implementation)(nil) // won't compile if missing implementation
package main
import "testing"
func TestToSnakeCase(t *testing.T) {
type testCase struct {
description string
input string
expected string
}
testCases := []testCase{
{
description: "empty string",
input: "",
expected: "",
}
}
for _, tc := range testCases {
t.Run(tc.description, func(t *testing.T) {
actual := ToSnakeCase(tc.input)
if actual != tc.expected {
t.Errorf("expected %s, got %s", tc.expected, actual)
}
})
}
}