Source File
builtin.go
Belonging Package
go101.org/nstd
package nstd
import (
)
// Generally, Panicf(format, v...) is a short form of panic(fmt.Sprintf(format, v...)).
// When format is blank, then it is a short form of panic(fmt.Sprint(v...)).
func ( string, ...any) bool {
if == "" {
panic(fmt.Sprint(...))
} else {
panic(fmt.Sprintf(, ...))
}
return true
}
// Must panics if err is not nil; otherwise, the T value is returned.
//
// See: https://github.com/golang/go/issues/58280
func [ any]( , error) {
if != nil {
panic()
}
return
}
// Must2 panics if err is not nil; otherwise, the T1 and T2 values are returned.
func [, any]( , , error) (, ) {
if != nil {
panic()
}
return ,
}
// Eval is used to ensure the evaluation order of some expressions
// in a statement.
//
// See:
//
// * https://go101.org/article/evaluation-orders.html
// * https://github.com/golang/go/issues/27804
// * https://github.com/golang/go/issues/36449
func [ any]( ) {
return
}
// ZeroOf[T]() and ZeroOf(valueOfT) both return the zero value of type T.
func [ any]() {
var
return
}
// Zero(p) zeros the value referenced by the pointer p.
// Zero is useful for resetting values of some unexported types,
// or resetting values of some other packages but without importing those packages.
func [ any]( *) {
var
* =
}
// New allocates a T value and initialize it with the specified one.
func [ any]( ) * {
return &
}
// SliceFrom is used to create a slice from some values of the same type.
// Some use scenarios:
// 1. Convert multiple results of a function call to a []any slice,
// then use the slice in fmt.Printf alike functions.
// 2. Construct a []T slice from some T values without using the []T{...} form.
//
// NOTE: SliceFrom(aSlice...) returns aSlice,
//
// See: https://github.com/golang/go/issues/61213
func [ any]( ...) [] {
return
}
// TypeAssert asserts an interface value x to type T.
// If the assertion succeeds, true is returned, othewise, false is returned.
// If into is not nil, then the concrete value of x will be assigned to
// the value referenced by into.
//
// See: https://github.com/golang/go/issues/65846
func [ any]( any, *) ( bool) {
if != nil {
*, = .()
} else {
_, = .()
}
return
}
// HasMapEntry checks whether or not a map contains an entry
// with the specified key.
func [ comparable, any]( map[], ) bool {
, := []
return
}
The pages are generated with Golds v0.7.0-preview. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |