Thanks to visit codestin.com
Credit goes to github.com

Skip to content
/ godef Public
forked from rogpeppe/godef

Print where symbols are defined in Go source code

License

Notifications You must be signed in to change notification settings

jjuliano/godef

 
 

Repository files navigation

godef

godef is a tool for finding the definition of a symbol in Go source code. It can read input from a file, stdin, or the current acme window and provide information about the symbol's definition, type, and other relevant details. It supports various output formats and debugging features.

Installation

To install godef, you need to have Go installed. Then, use the following command:

go install github.com/jjuliano/godef@latest

Usage

godef [flags] [expr]

Flags

  • -i: Read file from stdin.
  • -o int: File offset of identifier in stdin.
  • -debug: Enable debug mode.
  • -t: Print type information.
  • -a: Print public type and member information.
  • -A: Print all type and member information.
  • -f string: Go source filename.
  • -acme: Use current acme window.
  • -json: Output location in JSON format (ignores -t flag).
  • -cpuprofile string: Write CPU profile to this file.
  • -memprofile string: Write memory profile to this file.
  • -trace string: Write trace log to this file.

Examples

Find the definition of a symbol in a file

godef -f example.go -o 123

Read from stdin

cat example.go | godef -i -o 123

Use in an acme window

godef -acme

Output in JSON format

godef -f example.go -o 123 -json

Debugging

To enable debugging, use the -debug flag. This will print additional debug information to help diagnose issues.

Profiling

To profile the CPU or memory usage of godef, use the -cpuprofile and -memprofile flags respectively. These will write profile data to the specified files.

godef -f example.go -o 123 -cpuprofile cpu.prof
godef -f example.go -o 123 -memprofile mem.prof

Tracing

To enable tracing, use the -trace flag. This will write trace data to the specified file.

godef -f example.go -o 123 -trace trace.out

To view the trace, use the following command:

go tool trace view trace.out

License

This project is licensed under the BSD-3-Clause license. See the LICENSE file for details.

About

Print where symbols are defined in Go source code

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.5%
  • Makefile 0.5%