bytesconv.go
This file
Path
internal/bytesconv/bytesconv.go
21 lines · 719 bytes · Go
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than cf32d2d point at it.
chore(deps): bump github.com/pelletier/go-toml/v2 from 2.2.2 to 2.2.4 (#4212)dependabot[bot]before adoptioncf32d2d
lines 1–21why, one step back1// Copyright 2023 Gin Core Team. All rights reserved.2// Use of this source code is governed by a MIT style3// license that can be found in the LICENSE file.45package bytesconv67import (8 "unsafe"9)1011// StringToBytes converts string to byte slice without a memory allocation.12// For more details, see https://github.com/golang/go/issues/53003#issuecomment-1140276077.13func StringToBytes(s string) []byte {14 return unsafe.Slice(unsafe.StringData(s), len(s))15}1617// BytesToString converts byte slice to string without a memory allocation.18// For more details, see https://github.com/golang/go/issues/53003#issuecomment-1140276077.19func BytesToString(b []byte) string {20 return unsafe.String(unsafe.SliceData(b), len(b))21}