MCPcopy Index your code
hub / github.com/ccoVeille/go-safecast

github.com/ccoVeille/go-safecast @v2.0.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.0.1 ↗ · + Follow
87 symbols 178 edges 12 files 23 documented · 26% 15 cross-repo links updated 3d agov2.0.1 · 2026-05-28★ 895 open issues

Browse by type

Functions 69 Types & classes 18
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

package safecast_test

import ( "fmt"

"github.com/ccoveille/go-safecast/v2"

)

func Example() { var a int64

a = 42
b, err := safecast.Convert[int16](a) // everything is fine because 42 fits in int16
if err != nil {
    fmt.Println(err)
}
fmt.Println(b)

a = 255 + 1
_, err = safecast.Convert[uint8](a) // 256 is greater than uint8 maximum value
if err != nil {
    fmt.Println(err)
}

a = -1
_, err = safecast.Convert[uint64](a) // -1 cannot fit in uint64
if err != nil {
    fmt.Println(err)
}

str := "\x99" // ASCII code 153 for Trademark symbol
e := str[0]
_, err = safecast.Convert[int8](e)
if err != nil {
    fmt.Println(err)
}

// Output:
// 42
// conversion issue: 256 (int64) is greater than 255 (uint8): maximum value for this type exceeded
// conversion issue: -1 (int64) is less than 0 (uint64): minimum value for this type exceeded
// conversion issue: 153 (uint8) is greater than 127 (int8): maximum value for this type exceeded

}

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Function 53
Method 16
Struct 11
Interface 3
FuncType 2
TypeAlias 2

Languages

Go100%

Modules by API surface

parse_test.go16 symbols
conversion_test.go15 symbols
parse.go13 symbols
asserters_test.go13 symbols
conversion.go11 symbols
types.go10 symbols
types_test.go3 symbols
errors.go3 symbols
readme_test.go1 symbols
examples_test.go1 symbols
conversion_64bit_test.go1 symbols

For agents

$ claude mcp add go-safecast \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page