Go 中是否可以將一個字節(jié)轉(zhuǎn)換為空字符串?我試過了string(0),但結(jié)果是string長度為1:emptyString := ""nullByte := 0fmt.Printf("%T, %v - %T, %v", emptyString, len(emptyString), string(nullByte), len(string(nullByte)))輸出:string, 0 - string, 1我想這樣做的原因是我有一個函數(shù),它接受 abyte并將其轉(zhuǎn)換為 a string,并且我想向該函數(shù)提供空字符串。
是否可以使用 Go 中的 string() 將字節(jié)轉(zhuǎn)換為空字符串?
ibeautiful
2023-08-14 16:32:05