Monorepo for Tangled โ€” https://tangled.org

guard: read the motd from a file #382

merged
opened by ptr.pet targeting master from ptr.pet/core: master
0
by ptr.pet 2 comments
expand 1 commit
guard: read the motd from a file

this is looking good! couple of things:

  • we can simply open the file buffer, if there is an error, we can store strings.NewReader("default message")
  • instead of printing the string to stderr, we can use io.Copy from the file buffer to stderr

maybe something like this:

var motdReader io.Reader

if motdFile, err := os.Open("input.txt"); err != nil {
    motdReader = strings.NewReader("Welcome!")
} else {
    motdReader = file
}

io.Copy(os.Stderr, reader)

done! should be like that now

sign up or login to add to the discussion
1
by ptr.pet 0 comments
expand 1 commit
guard: read the motd from a file
pull request successfully merged
sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 2
AT URI
at://did:plc:dfl62fgb7wtjj3fcbb72naae/sh.tangled.repo.pull/3lvc4u7joma22