JetBrains Fleet 1.44 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

Can be applied in

:

Variable declaration :=

$NAME$ := $VALUE$

Statement

bench

Benchmark

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

File

consts

Constants declaration

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

File

Statement

err

If error

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

Statement

fori

Indexed for loop

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

Statement

forr

For range loop

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

Statement

fuzz

Fuzzing

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

File

imports

Imports declaration

import ( "$END$" )

File

init

Init function

func init() { $END$ }

File

iota

Iota constant declaration

const $NAME$ $TYPE$ = iota

File

Statement

main

Main function

func main() { $END$ }

File

map

Map type

map[$KEY_TYPE$]$VALUE_TYPE$

Type

meth

Method

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

File

p

Package declaration

package $NAME$

File

printf

printf

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

Statement

test

Test

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

File

types

Types declaration

type ( $END$ )

File

Statement

vars

Variables declaration

var ( $NAME$ = $VALUE$$END$ )

File

Statement

Last modified: 23 September 2024