From 2a909b0888a485d619af20b30f21fe31f0de8f6d Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 23 Mar 2025 12:02:14 +0800 Subject: Separate unsafe operations to unsafe.go --- main.go | 5 ----- unsafe.go | 7 +++++++ 2 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 unsafe.go diff --git a/main.go b/main.go index 0c44222..bef172b 100644 --- a/main.go +++ b/main.go @@ -15,7 +15,6 @@ import ( "net/url" "strings" "time" - "unsafe" ) var ( @@ -193,7 +192,3 @@ func makeSignedToken(request *http.Request) []byte { func proxyRequest(writer http.ResponseWriter, request *http.Request) { reverseProxy.ServeHTTP(writer, request) } - -func stringToBytes(s string) (bytes []byte) { - return unsafe.Slice(unsafe.StringData(s), len(s)) -} diff --git a/unsafe.go b/unsafe.go new file mode 100644 index 0000000..4a7b2d0 --- /dev/null +++ b/unsafe.go @@ -0,0 +1,7 @@ +package main + +import "unsafe" + +func stringToBytes(s string) (bytes []byte) { + return unsafe.Slice(unsafe.StringData(s), len(s)) +} -- cgit v1.2.3