X7ROOT File Manager
Current Path:
/opt/golang/1.17.2/src/reflect
opt
/
golang
/
1.17.2
/
src
/
reflect
/
📁
..
📄
abi.go
(13.72 KB)
📄
abi_test.go
(25.84 KB)
📄
all_test.go
(183.35 KB)
📄
asm_386.s
(1.07 KB)
📄
asm_amd64.s
(3.02 KB)
📄
asm_arm.s
(1.13 KB)
📄
asm_arm64.s
(1.1 KB)
📄
asm_mips64x.s
(1.19 KB)
📄
asm_mipsx.s
(1.18 KB)
📄
asm_ppc64x.s
(1.3 KB)
📄
asm_riscv64.s
(1.09 KB)
📄
asm_s390x.s
(1.1 KB)
📄
asm_wasm.s
(1.15 KB)
📄
deepequal.go
(6.82 KB)
📄
example_test.go
(3.73 KB)
📄
export_test.go
(3.61 KB)
📁
internal
📄
makefunc.go
(6.19 KB)
📄
set_test.go
(5.77 KB)
📄
swapper.go
(1.96 KB)
📄
tostring_test.go
(2.14 KB)
📄
type.go
(86.11 KB)
📄
value.go
(97.32 KB)
📄
visiblefields.go
(2.96 KB)
📄
visiblefields_test.go
(4.95 KB)
Editing: tostring_test.go
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Formatting of reflection types and values for debugging. // Not defined as methods so they do not need to be linked into most binaries; // the functions are not used by the library itself, only in tests. package reflect_test import ( . "reflect" "strconv" ) // valueToString returns a textual representation of the reflection value val. // For debugging only. func valueToString(val Value) string { var str string if !val.IsValid() { return "<zero Value>" } typ := val.Type() switch val.Kind() { case Int, Int8, Int16, Int32, Int64: return strconv.FormatInt(val.Int(), 10) case Uint, Uint8, Uint16, Uint32, Uint64, Uintptr: return strconv.FormatUint(val.Uint(), 10) case Float32, Float64: return strconv.FormatFloat(val.Float(), 'g', -1, 64) case Complex64, Complex128: c := val.Complex() return strconv.FormatFloat(real(c), 'g', -1, 64) + "+" + strconv.FormatFloat(imag(c), 'g', -1, 64) + "i" case String: return val.String() case Bool: if val.Bool() { return "true" } else { return "false" } case Ptr: v := val str = typ.String() + "(" if v.IsNil() { str += "0" } else { str += "&" + valueToString(v.Elem()) } str += ")" return str case Array, Slice: v := val str += typ.String() str += "{" for i := 0; i < v.Len(); i++ { if i > 0 { str += ", " } str += valueToString(v.Index(i)) } str += "}" return str case Map: t := typ str = t.String() str += "{" str += "<can't iterate on maps>" str += "}" return str case Chan: str = typ.String() return str case Struct: t := typ v := val str += t.String() str += "{" for i, n := 0, v.NumField(); i < n; i++ { if i > 0 { str += ", " } str += valueToString(v.Field(i)) } str += "}" return str case Interface: return typ.String() + "(" + valueToString(val.Elem()) + ")" case Func: v := val return typ.String() + "(" + strconv.FormatUint(uint64(v.Pointer()), 10) + ")" default: panic("valueToString: can't print type " + typ.String()) } }
Upload File
Create Folder