Skip to content

Instantly share code, notes, and snippets.

@nsf
Created October 20, 2010 01:08
Show Gist options
  • Select an option

  • Save nsf/635561 to your computer and use it in GitHub Desktop.

Select an option

Save nsf/635561 to your computer and use it in GitHub Desktop.
Syntax:
[:CLASS ][!]ARG1 [!]ARG2
or
[:CLASS ][!]ARG1.ARG2
Where CLASS is:
c - const
v - var
m - method
t - type
f - func
Default CLASS is:
tcfv (type/const/func/var)
Exclamation mark ('!') means "show the best match only". In the second syntax
form, exclamation mark is applied to both arguments.
ARG1 is used as a pattern to search for an entity of a certain class, which
matches that pattern:
c - search for a named const group, then for a const inside unnamed group and
then for an individual const entity
v - search for a var group, then for a var inside unnamed group and then for
an individual var entity
m - search for methods of type that matches ARG1 (for this class, '!'
modificator is implicitly enabled, e.g. search request only shows all
methods of the best matched type)
t - search for a type
f - search for a func
ARG2 is used as a pattern to filter 'm' (method) search results only.
Examples:
--------------------------------------------------------------
`:tm !Rectangle` - Search for a type and methods of that type, show only the best
match (note that '!' is implicit for 'm', but not for 't')
--------------------------------------------------------------
`:tcfv Expr` or `Expr` - Search for a type/const/func/var that matches 'Expr'
pattern, multiple results are displayed that way:
t, c, f, v, t, c, v, f, t, c, f, v, t, c, f, v, ...
It there is one type, two consts and four funcs, the output will be:
t, c, f, c, f, f, f
--------------------------------------------------------------
`:fc !Magic` - Search for the best matched func and const using pattern 'Magic'.
--------------------------------------------------------------
`!vspec` - Search for the best matched type/const/func/var using pattern
'vspec', for example in "go/ast" package it will show ValueSpec type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment