ident

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package ident provides functions for parsing and converting identifier names between various naming convention. It has support for MixedCaps, lowerCamelCase, and SCREAMING_SNAKE_CASE naming conventions.

Example (LowerCamelCaseToMixedCaps)
package main

import (
	"fmt"

	"github.com/cli/shurcooL-graphql/ident"
)

func main() {
	fmt.Println(ident.ParseLowerCamelCase("clientMutationId").ToMixedCaps())

}
Output:

ClientMutationID
Example (MixedCapsToLowerCamelCase)
package main

import (
	"fmt"

	"github.com/cli/shurcooL-graphql/ident"
)

func main() {
	fmt.Println(ident.ParseMixedCaps("ClientMutationID").ToLowerCamelCase())

}
Output:

clientMutationId
Example (ScreamingSnakeCaseToMixedCaps)
package main

import (
	"fmt"

	"github.com/cli/shurcooL-graphql/ident"
)

func main() {
	fmt.Println(ident.ParseScreamingSnakeCase("CLIENT_MUTATION_ID").ToMixedCaps())

}
Output:

ClientMutationID

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Name

type Name []string

Name is an identifier name, broken up into individual words.

func ParseLowerCamelCase

func ParseLowerCamelCase(name string) Name

ParseLowerCamelCase parses a lowerCamelCase identifier name.

E.g., "clientMutationId" -> {"client", "Mutation", "Id"}.

func ParseMixedCaps

func ParseMixedCaps(name string) Name

ParseMixedCaps parses a MixedCaps identifier name.

E.g., "ClientMutationID" -> {"Client", "Mutation", "ID"}.

func ParseScreamingSnakeCase

func ParseScreamingSnakeCase(name string) Name

ParseScreamingSnakeCase parses a SCREAMING_SNAKE_CASE identifier name.

E.g., "CLIENT_MUTATION_ID" -> {"CLIENT", "MUTATION", "ID"}.

func (Name) ToLowerCamelCase

func (n Name) ToLowerCamelCase() string

ToLowerCamelCase expresses identifier name in lowerCamelCase naming convention.

E.g., "clientMutationId".

func (Name) ToMixedCaps

func (n Name) ToMixedCaps() string

ToMixedCaps expresses identifier name in MixedCaps naming convention.

E.g., "ClientMutationID".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL