1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-09-15 18:57:04 +00:00

refactor(misc): replace overkill usages of printf

This commit is contained in:
jvoisin 2025-08-27 09:26:51 +02:00
parent e8f5c2446c
commit 70330754d2
6 changed files with 8 additions and 7 deletions

View file

@ -5,6 +5,7 @@ package cli // import "miniflux.app/v2/internal/cli"
import ( import (
"bufio" "bufio"
"errors"
"fmt" "fmt"
"os" "os"
"strings" "strings"
@ -16,7 +17,7 @@ func askCredentials() (string, string) {
fd := int(os.Stdin.Fd()) fd := int(os.Stdin.Fd())
if !term.IsTerminal(fd) { if !term.IsTerminal(fd) {
printErrorAndExit(fmt.Errorf("this is not an interactive terminal, exiting")) printErrorAndExit(errors.New("this is not an interactive terminal, exiting"))
} }
fmt.Print("Enter Username: ") fmt.Print("Enter Username: ")
@ -30,6 +31,6 @@ func askCredentials() (string, string) {
defer term.Restore(fd, state) defer term.Restore(fd, state)
bytePassword, _ := term.ReadPassword(fd) bytePassword, _ := term.ReadPassword(fd)
fmt.Printf("\n") fmt.Print("\n")
return strings.TrimSpace(username), strings.TrimSpace(string(bytePassword)) return strings.TrimSpace(username), strings.TrimSpace(string(bytePassword))
} }

View file

@ -263,6 +263,6 @@ func Parse() {
} }
func printErrorAndExit(err error) { func printErrorAndExit(err error) {
fmt.Fprintf(os.Stderr, "%v\n", err) fmt.Fprintln(os.Stderr, err)
os.Exit(1) os.Exit(1)
} }

View file

@ -793,7 +793,7 @@ func (h *handler) streamItemContentsHandler(w http.ResponseWriter, r *http.Reque
Content: entry.Content, Content: entry.Content,
}, },
Origin: contentItemOrigin{ Origin: contentItemOrigin{
StreamID: fmt.Sprintf("feed/%d", entry.FeedID), StreamID: fmt.Sprintf(feedPrefix+"%d", entry.FeedID),
Title: entry.Feed.Title, Title: entry.Feed.Title,
HTMLUrl: entry.Feed.SiteURL, HTMLUrl: entry.Feed.SiteURL,
}, },

View file

@ -50,7 +50,7 @@ func (c *Client) SaveURL(entryURL string) error {
return fmt.Errorf("karakeep: unable to create request: %v", err) return fmt.Errorf("karakeep: unable to create request: %v", err)
} }
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", c.apiToken)) req.Header.Set("Authorization", "Bearer "+c.apiToken)
req.Header.Set("Content-Type", "application/json") req.Header.Set("Content-Type", "application/json")
req.Header.Set("User-Agent", "Miniflux/"+version.Version) req.Header.Set("User-Agent", "Miniflux/"+version.Version)

View file

@ -90,7 +90,7 @@ func (c *Client) makeRequest(payload any) error {
// See https://docs.ntfy.sh/publish/#access-tokens // See https://docs.ntfy.sh/publish/#access-tokens
if c.ntfyApiToken != "" { if c.ntfyApiToken != "" {
request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", c.ntfyApiToken)) request.Header.Set("Authorization", "Bearer "+c.ntfyApiToken)
} }
// See https://docs.ntfy.sh/publish/#username-password // See https://docs.ntfy.sh/publish/#username-password

View file

@ -140,7 +140,7 @@ func (h *handler) mediaProxy(w http.ResponseWriter, r *http.Request) {
b.WithHeader("Content-Type", resp.Header.Get("Content-Type")) b.WithHeader("Content-Type", resp.Header.Get("Content-Type"))
if filename := path.Base(parsedMediaURL.Path); filename != "" { if filename := path.Base(parsedMediaURL.Path); filename != "" {
b.WithHeader("Content-Disposition", fmt.Sprintf(`inline; filename="%s"`, filename)) b.WithHeader("Content-Disposition", `inline; filename="`+filename+`"`)
} }
forwardedResponseHeader := [...]string{"Content-Encoding", "Content-Type", "Content-Length", "Accept-Ranges", "Content-Range"} forwardedResponseHeader := [...]string{"Content-Encoding", "Content-Type", "Content-Length", "Accept-Ranges", "Content-Range"}