Skip to content

Commit

Permalink
Add minor go file format changes (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
philoserf committed Sep 26, 2023
1 parent 3bad588 commit dfd3fef
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cmd/about.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type aboutCommand struct {
buildHash string
}

func NewAboutCommand(version string, buildHash string) AboutCommand {
func NewAboutCommand(version, buildHash string) AboutCommand {
return &aboutCommand{
version: version,
buildHash: buildHash,
Expand Down
2 changes: 0 additions & 2 deletions cmd/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type editCommand struct {

func NewEditCommand(ctx stoic.Context, value string) EditCommand {
date, err := naturaldate.Parse(value, time.Now())

if err != nil {
fmt.Println("Error parsing date:", err)
os.Exit(1)
Expand All @@ -42,7 +41,6 @@ func (e *editCommand) Date() time.Time {
func (e *editCommand) Run() {
entry := stoic.NewEntry(e.ctx, e.date)
err := e.ctx.OpenInEditor(entry)

if err != nil {
fmt.Println("Error running program:", err)
os.Exit(1)
Expand Down
1 change: 0 additions & 1 deletion cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ func (m model) View() string {
}

func OpenFileInEditor(filepath string, ctx stoic.Context) error {

cmd := exec.Command(ctx.Editor(), filepath)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
Expand Down
2 changes: 1 addition & 1 deletion cmd/quote.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (
BorderRight(true).
BorderBottom(true)

authoredBy = lipgloss.NewStyle().SetString("©").
authoredBy = lipgloss.NewStyle().SetString("").
PaddingRight(1).
Foreground(foreground).
String()
Expand Down
15 changes: 8 additions & 7 deletions internal/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import (
homedir "github.com/mitchellh/go-homedir"
)

const DEFAULT_EDITOR = "nano"
const DEFAULT_DIRECTORY = "~/Journal/"
const DEFAULT_EXTENSION = "md"
const (
DEFAULT_EDITOR = "nano"
DEFAULT_DIRECTORY = "~/Journal/"
DEFAULT_EXTENSION = "md"
)

type Context interface {
Directory() string
Expand All @@ -31,7 +33,7 @@ type context struct {
template string
}

func NewContext(homeDir string, fileExtension string, editor string, template string) Context {
func NewContext(homeDir, fileExtension, editor, template string) Context {
directory := expandDir(homeDir)

if fileExtension == "" {
Expand Down Expand Up @@ -75,7 +77,7 @@ func (ctx *context) OpenInEditor(entry Entry) error {
return cmd.Run()
}

func createFileFromTemplate(filename string, template_path string) error {
func createFileFromTemplate(filename, template_path string) error {
file, err := os.Create(filename)
if err != nil {
return err
Expand Down Expand Up @@ -148,8 +150,7 @@ func (ctx context) Files() []string {

func createDirectoryIfMissing(dir string) error {
if _, err := os.Stat(dir); os.IsNotExist(err) {
err := os.MkdirAll(dir, 0755)

err := os.MkdirAll(dir, 0o755)
if err != nil {
return err
}
Expand Down
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import (
stoic "github.com/skatkov/stoic/internal"
)

var BinaryVersion string // Set via build flag
var BinaryBuildHash string // Set via build flag
var (
BinaryVersion string // Set via build flag
BinaryBuildHash string // Set via build flag
)

func main() {
ctx := stoic.NewContext(
Expand All @@ -38,7 +40,6 @@ func main() {
cmd.NewQuoteCommand().Run()
default:
err := ctx.OpenInEditor(stoic.NewEntry(ctx, time.Now()))

if err != nil {
fmt.Println(err)
}
Expand Down

0 comments on commit dfd3fef

Please sign in to comment.