JetBrains Fleet 1.32 Help

List of Go live templates

Use live templates to insert common constructs into your code, such as loops, conditions, declarations, or print statements.

To expand a code snippet, type the corresponding template abbreviation and press . Keep pressing to jump from one variable in the template to the next one. Press ⇧ ⇥ to move to the previous variable.

This table summarizes the live templates that you can use with your Go code.

Abbreviation

Description

Template text

:

Variable declaration :=

$NAME$ := $VALUE$
bench

Benchmark

func Benchmark$NAME$(b *testing.B) { for i := 0; i < b.N; i++ { $END$ } }
consts

Constants declaration

const ( $NAME$ = $VALUE$$END$ )
err

If error

if $ERR$ != nil { $END$ }
fori

Indexed for loop

for $INDEX$ := 0; $INDEX$ < $LIMIT$; $INDEX$++ { $END$ }
forr

For range loop

for $KEY$, $VALUE$ := range $COLLECTION$ { $END$ }
fuzz

Fuzzing

func Fuzz$NAME$(f *testing.F) { $END$ }
imports

Imports declaration

import ( "$END$" )
init

Init function

func init() { $END$ }
iota

Iota constant declaration

const $NAME$ $TYPE$ = iota
main

Main function

func main() { $END$ }
map

Map type

map[$KEY_TYPE$]$VALUE_TYPE$
meth

Method

func ($RECEIVER$ $TYPE_1$) $NAME$($PARAMS$) $TYPE_2$ { $END$ }
p

Package declaration

package $NAME$
printf

printf

fmt.Printf("$END$",$VAR$)
test

Test

func Test$NAME$(t *testing.T) { $END$ }
types

Types declaration

type ( $END$ )
vars

Variables declaration

var ( $NAME$ = $VALUE$$END$ )
Last modified: 22 March 2024