Help us shape the future of Go! Take the 2026 Go Developer Survey

editor

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package editor opens private note drafts in the user's external editor.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Draft

type Draft struct {
	Path string
	// contains filtered or unexported fields
}

Draft owns a temporary AsciiDoc file. It never writes into the vault.

func New

func New(source []byte) (*Draft, error)

New copies source into a private temporary .adoc file and retains the initial snapshot.

func (*Draft) Close

func (draft *Draft) Close()

Close discards the draft file, including drafts explicitly marked for retention.

func (*Draft) Command

func (draft *Draft) Command(ctx context.Context) *exec.Cmd

Command resolves EDITOR, then VISUAL, then vi, supporting shell arguments. The draft path is passed separately so spaces and shell syntax in it remain literal.

func (*Draft) Finish

func (draft *Draft) Finish() (string, error)

Finish removes unchanged drafts and retains unfinished work when the UI exits.

func (*Draft) Keep

func (draft *Draft) Keep()

Keep preserves even an unchanged draft after a failed edit or explicit request.

func (*Draft) Read

func (draft *Draft) Read() ([]byte, error)

Read returns the current draft bytes after the external editor has exited.

func (*Draft) Write

func (draft *Draft) Write(source []byte) error

Write refreshes the private draft after managed metadata has been saved.

Jump to

Keyboard shortcuts

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