https://github.com/akshayjshah/must
A generic equivalent to Go's template.Must
https://github.com/akshayjshah/must
go golang
Last synced: 2 months ago
JSON representation
A generic equivalent to Go's template.Must
- Host: GitHub
- URL: https://github.com/akshayjshah/must
- Owner: akshayjshah
- License: mit
- Created: 2023-05-08T22:24:32.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-07T01:13:19.000Z (over 1 year ago)
- Last Synced: 2025-01-23T00:12:03.102Z (4 months ago)
- Topics: go, golang
- Language: Makefile
- Homepage: https://pkg.go.dev/go.akshayshah.org/must
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
must
====[](https://github.com/akshayjshah/must/actions/workflows/ci.yaml)
[](https://goreportcard.com/report/go.akshayshah.org/must)
[](https://pkg.go.dev/go.akshayshah.org/must)`must` provides a generic equivalent of the Go standard library's
[template.Must][] or [regexp.MustCompile][]: a wrapper that converts errors to
panics. This is usually undesirable, but it's both convenient and safe when
creating global variables from pure functions and static inputs.## Installation
```
go get go.akshayshah.org/must
```## Usage
```go
package mainimport (
"fmt"
"net/url"
)var google = Must(url.Parse("https://www.google.com"))
func main() {
fmt.Println(google.Scheme)
}
```## Status: Stable
This module is stable. It supports the [two most recent major
releases][go-support-policy] of Go.Within those parameters, `must` follows semantic versioning. No
breaking changes will be made without incrementing the major version.## Legal
Offered under the [MIT license][license].
[cmp]: https://pkg.go.dev/github.com/google/go-cmp/cmp
[go-support-policy]: https://golang.org/doc/devel/release#policy
[license]: https://github.com/akshayjshah/must/blob/main/LICENSE
[template.Must]: https://pkg.go.dev/text/template#Must
[regexp.MustCompile]: https://pkg.go.dev/regexp#MustCompile