editorconfig-core-go.v1: gopkg.in/editorconfig/editorconfig-core-go.v1 Index | Files

package editorconfig

import "gopkg.in/editorconfig/editorconfig-core-go.v1"

Package editorconfig can be used to parse and generate editorconfig files. For more information about editorconfig, see http://editorconfig.org/

Index

Package Files

editorconfig.go

Constants

const (
    IndentStyleTab    = "tab"
    IndentStyleSpaces = "space"
)

IndentStyle possible values

const (
    EndOfLineLf   = "lf"
    EndOfLineCr   = "cr"
    EndOfLineCrLf = "crlf"
)

EndOfLine possible values

const (
    CharsetLatin1  = "latin1"
    CharsetUTF8    = "utf-8"
    CharsetUTF16BE = "utf-16be"
    CharsetUTF16LE = "utf-16le"
)

Charset possible values

const (
    ConfigNameDefault = ".editorconfig"
)

type Definition Uses

type Definition struct {
    Selector string `ini:"-" json:"-"`

    Charset                string `ini:"charset" json:"charset,omitempty"`
    IndentStyle            string `ini:"indent_style" json:"indent_style,omitempty"`
    IndentSize             string `ini:"indent_size" json:"indent_size,omitempty"`
    TabWidth               int    `ini:"tab_width" json:"tab_width,omitempty"`
    EndOfLine              string `ini:"end_of_line" json:"end_of_line,omitempty"`
    TrimTrailingWhitespace bool   `ini:"trim_trailing_whitespace" json:"trim_trailing_whitespace,omitempty"`
    InsertFinalNewline     bool   `ini:"insert_final_newline" json:"insert_final_newline,omitempty"`

    Raw map[string]string `ini:"-" json:"-"`
}

Definition represents a definition inside the .editorconfig file. E.g. a section of the file. The definition is composed of the selector ("*", "*.go", "*.{js.css}", etc), plus the properties of the selected files.

func GetDefinitionForFilename Uses

func GetDefinitionForFilename(filename string) (*Definition, error)

GetDefinitionForFilename given a filename, searches for .editorconfig files, starting from the file folder, walking through the previous folders, until it reaches a folder with `root = true`, and returns the right editorconfig definition for the given file.

func GetDefinitionForFilenameWithConfigname Uses

func GetDefinitionForFilenameWithConfigname(filename string, configname string) (*Definition, error)

func (*Definition) InsertToIniFile Uses

func (d *Definition) InsertToIniFile(iniFile *ini.File)

type Editorconfig Uses

type Editorconfig struct {
    Root        bool
    Definitions []*Definition
}

Editorconfig represents a .editorconfig file. It is composed by a "root" property, plus the definitions defined in the file.

func ParseBytes Uses

func ParseBytes(data []byte) (*Editorconfig, error)

ParseBytes parses from a slice of bytes.

func ParseFile Uses

func ParseFile(f string) (*Editorconfig, error)

ParseFile parses from a file.

func (*Editorconfig) GetDefinitionForFilename Uses

func (e *Editorconfig) GetDefinitionForFilename(name string) *Definition

GetDefinitionForFilename returns a definition for the given filename. The result is a merge of the selectors that matched the file. The last section has preference over the priors.

func (*Editorconfig) Save Uses

func (e *Editorconfig) Save(filename string) error

Save saves the Editorconfig to a compatible INI file.

func (*Editorconfig) Serialize Uses

func (e *Editorconfig) Serialize() ([]byte, error)

Serialize converts the Editorconfig to a slice of bytes, containing the content of the file in the INI format.

Package editorconfig imports 8 packages (graph) and is imported by 16 packages. Updated 2018-10-06. Refresh now. Tools for package owners.