Skip to content

Instantly share code, notes, and snippets.

View udhos's full-sized avatar
👾
Wondering

udhos

👾
Wondering
  • São Paulo, Brazil
View GitHub Profile
@udhos
udhos / golang_string_to_bytes_and_back_again.md
Created May 25, 2023 06:14
golang_string_to_bytes_and_back_again

bytes<->string without allocation. However, bytes can't be changed.

// StringToBytes converts string to byte slice without a memory allocation.
// The bytes must not be modified; doing so can cause
// the program to crash or behave unpredictably.
func StringToBytes(s string) []byte {
    return unsafe.Slice(unsafe.StringData(s), len(s))
}
@udhos
udhos / kubernetes operator.md
Last active November 1, 2023 07:10
kubernetes operator

Kubebuilder does not exist as an example to copy-paste, but instead provides powerful libraries and tools to simplify building and publishing Kubernetes APIs from scratch. It provides a plugin architecture allowing users to take advantage of optional helpers and features.

Kubebuilder is developed on top of the controller-runtime and controller-tools libraries.

Kubebuilder is extensible and can be used as a library in other projects. Operator-SDK is a good example of a project that uses Kubebuilder as a library.

Sample controller: https://github.com/kubernetes/sample-controller

Book: https://book.kubebuilder.io/

@udhos
udhos / dynamodb getitem x query x scan.md
Last active December 16, 2022 03:47
dynamodb getitem x query x scan

dynamodb getitem x query x scan

@udhos
udhos / golang json parser validation.md
Created May 27, 2022 15:01
golang json parser validation