File Style

Overview

goctl generation supports formatting of files and folders by naming styles that meet the normal reading habits of different developers, although in Golang, folders and filename instructions are recommended to use a full lowercase style, refer to Go Style.

Formatting symbols

In goctl code generated, the naming style of the files and folders can be formatted by go and zero compart-formatted symbols, such as common styled symbols below:

  • lowercase: gozero
  • camelcase: goZero
  • snakecase: go_zero

Formatting Symbol Table Reference

Assume that we have a source string welcome_to_go_nerwith reference formatting table:

Formatting symbolsFormatted stringNote
gozerowelcometogozerolower case
goZerowelcomeToGoZerocamel case
gozerowelcome_to_go_zerosnake case
Go#zeroWelcome#to#go#zeroCustom separator like separator #
GOZEROWELCOMETOGOZEROupper case
_go#zerowelcome#to#go#zeroPrefix, suffix and custom separators, use _ as prefix and suffix, use # as separator

::note illegal symbol

  • go
  • gOZero
  • zero
  • goZEro
  • goZERo
  • goZeRo
  • foo :::

Usage

Formatting symbols used when goctl codes are generated by style parameters to control formatters, e.g.:

  1. $ goctl api new demo --style gozero
  2. $ goctl api new demo --style go_zero
  3. $ goctl api new demo --style goZero