Documentation ¶
Overview ¶
Package editor provides simple wrappers for interacting with an environment configured text editor. The editor command is taken from the environment variable EDITOR and the package variable DefaultEditor will be used if EDITOR is not set.
Index ¶
Constants ¶
const EditorVar = "EDITOR"
EditorVar specifies the environment variable we use to discover the editor command.
Variables ¶
var ( // DefaultEditor is used if the user does not have EDITOR specified. DefaultEditor = "" // ErrNoEditor indicates that no EDITOR was set in the environment. ErrNoEditor = fmt.Errorf( "the $%s environment variable is empty or unset. Please set $%s to a path within $PATH to the command-line editor of your choice (e.g. /usr/bin/vi or /usr/bin/emacs)", EditorVar, EditorVar, ) )
Functions ¶
func EditPath ¶
EditPath opens a specified path in the configured editor. If the path doesn't exist or fails to open then an error is returned.
func EditText ¶
EditText opens an editor with the initial contents populated from the provided string; the edited string is returned.
func EditTextType ¶
EditTextType takes a string that should be edited and opens an editor with that content preloaded; it returns the edited string. If ext is not empty it will be used as the file extension.
In the event of an error an empty string and the error will be returned.
Types ¶
This section is empty.