MCPcopy Index your code
hub / github.com/alecthomas/repr

github.com/alecthomas/repr @v0.5.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.5.2 ↗ · + Follow
73 symbols 218 edges 2 files 21 documented · 29% 15 cross-repo links updated 15d ago★ 1792 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Python's repr() for Go CircleCI

This package attempts to represent Go values in a form that can be used almost directly in Go source code.

Unfortunately, some values (such as pointers to basic types) can not be represented directly in Go. These values will be represented as &<value>. eg. &23

Example

type test struct {
  S string
  I int
  A []int
}

func main() {
  repr.Print(&test{
    S: "String",
    I: 123,
    A: []int{1, 2, 3},
  })
}

Outputs

&main.test{S: "String", I: 123, A: []int{1, 2, 3}}

Why repr and not pp?

pp is designed for printing coloured output to consoles, with (seemingly?) no way to disable this. If you don't want coloured output (eg. for use in diffs, logs, etc.) repr is for you.

Why repr and not go-spew?

Repr deliberately contains much less metadata about values. It is designed to (generally) be copyable directly into source code.

Compare go-spew:

(parser.expression) (len=1 cap=1) {
 (parser.alternative) (len=1 cap=1) {
  ([]interface {}) (len=1 cap=1) {
   (*parser.repitition)(0xc82000b220)({
    expression: (parser.expression) (len=2 cap=2) {
     (parser.alternative) (len=1 cap=1) {
      ([]interface {}) (len=1 cap=1) {
       (parser.str) (len=1) "a"
      }
     },
     (parser.alternative) (len=1 cap=1) {
      ([]interface {}) (len=1 cap=1) {
       (*parser.self)(0x593ef0)({
       })
      }
     }
    }
   })
  }
 }
}

To repr:

parser.expression{
  parser.alternative{
    []interface {}{
      &parser.repitition{
        expression: parser.expression{
          parser.alternative{
            []interface {}{
              parser.str("a"),
            },
          },
          parser.alternative{
            []interface {}{
              &parser.self{              },
            },
          },
        },
      },
    },
  },
}

Extension points exported contracts — how you extend this code

Option (FuncType)
An Option modifies the default behaviour of a Printer.
repr.go

Core symbols most depended-on inside this repo

String
called by 34
repr.go
substAny
called by 6
repr.go
Indent
called by 5
repr.go
New
called by 4
repr.go
IsZero
called by 4
repr.go
OmitEmpty
called by 3
repr.go
Print
called by 2
repr.go
reprValue
called by 2
repr.go

Shape

Function 51
Struct 10
Method 9
FuncType 1
Interface 1
TypeAlias 1

Languages

Go100%

Modules by API surface

repr_test.go45 symbols
repr.go28 symbols

For agents

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

⬇ download graph artifact