From b861060663ed2ce35c4ecd65f5d2d7e333e21165 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sat, 05 Apr 2025 18:39:29 +0800 Subject: [PATCH] Move FirstOrPanic into this module --- http_handle_repo_commit.go | 2 +- misc/misc.go | 8 ++++++++ diff --git a/http_handle_repo_commit.go b/http_handle_repo_commit.go index 5ac315e293f112a2d8616f7e8f2faac0150c8154..02121a288ba59681fb4d82dbc2d59c8303971cf9 100644 --- a/http_handle_repo_commit.go +++ b/http_handle_repo_commit.go @@ -13,7 +13,7 @@ "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing/filemode" "github.com/go-git/go-git/v5/plumbing/format/diff" "github.com/go-git/go-git/v5/plumbing/object" - "go.lindenii.runxiyu.org/lindenii-common/misc" + "go.lindenii.runxiyu.org/forge/misc" ) // usableFilePatch is a [diff.FilePatch] that is structured in a way more diff --git a/misc/misc.go b/misc/misc.go new file mode 100644 index 0000000000000000000000000000000000000000..bc48486121fc20ba406e1f4ef8dc18f86fd4e980 --- /dev/null +++ b/misc/misc.go @@ -0,0 +1,8 @@ +package misc + +func FirstOrPanic[T any](v T, err error) T { + if err != nil { + panic(err) + } + return v +} -- 2.48.1