diff --git a/internal/client/accounts.go b/internal/client/accounts.go index fff08b3..9dc00d0 100644 --- a/internal/client/accounts.go +++ b/internal/client/accounts.go @@ -20,7 +20,7 @@ func (g *Client) VerifyCredentials() (model.Account, error) { var account model.Account if err := g.sendRequest(http.MethodGet, url, nil, &account); err != nil { - return model.Account{}, fmt.Errorf("received an error after sending the request to verify the credentials; %w", err) + return model.Account{}, fmt.Errorf("received an error after sending the request to verify the credentials: %w", err) } return account, nil @@ -33,7 +33,7 @@ func (g *Client) GetAccount(accountURI string) (model.Account, error) { var account model.Account if err := g.sendRequest(http.MethodGet, url, nil, &account); err != nil { - return model.Account{}, fmt.Errorf("received an error after sending the request to get the account information; %w", err) + return model.Account{}, fmt.Errorf("received an error after sending the request to get the account information: %w", err) } return account, nil @@ -46,11 +46,11 @@ func (g *Client) GetAccountRelationship(accountID string) (model.AccountRelation var relationships []model.AccountRelationship if err := g.sendRequest(http.MethodGet, url, nil, &relationships); err != nil { - return model.AccountRelationship{}, fmt.Errorf("received an error after sending the request to get the account relationship; %w", err) + return model.AccountRelationship{}, fmt.Errorf("received an error after sending the request to get the account relationship: %w", err) } if len(relationships) != 1 { - return model.AccountRelationship{}, fmt.Errorf("unexpected number of account relationships returned; want 1, got %d", len(relationships)) + return model.AccountRelationship{}, fmt.Errorf("unexpected number of account relationships returned: want 1, got %d", len(relationships)) } return relationships[0], nil @@ -65,14 +65,14 @@ type FollowAccountForm struct { func (g *Client) FollowAccount(form FollowAccountForm) error { data, err := json.Marshal(form) if err != nil { - return fmt.Errorf("unable to marshal the form; %w", err) + return fmt.Errorf("unable to marshal the form: %w", err) } requestBody := bytes.NewBuffer(data) url := g.Authentication.Instance + fmt.Sprintf("/api/v1/accounts/%s/follow", form.AccountID) if err := g.sendRequest(http.MethodPost, url, requestBody, nil); err != nil { - return fmt.Errorf("received an error after sending the follow request; %w", err) + return fmt.Errorf("received an error after sending the follow request: %w", err) } return nil @@ -82,7 +82,7 @@ func (g *Client) UnfollowAccount(accountID string) error { url := g.Authentication.Instance + fmt.Sprintf("/api/v1/accounts/%s/unfollow", accountID) if err := g.sendRequest(http.MethodPost, url, nil, nil); err != nil { - return fmt.Errorf("received an error after sending the request to unfollow the account; %w", err) + return fmt.Errorf("received an error after sending the request to unfollow the account: %w", err) } return nil @@ -94,7 +94,7 @@ func (g *Client) GetFollowers(accountID string, limit int) (model.AccountList, e accounts := make([]model.Account, limit) if err := g.sendRequest(http.MethodGet, url, nil, &accounts); err != nil { - return model.AccountList{}, fmt.Errorf("received an error after sending the request to get the list of followers; %w", err) + return model.AccountList{}, fmt.Errorf("received an error after sending the request to get the list of followers: %w", err) } followers := model.AccountList{ @@ -111,7 +111,7 @@ func (g *Client) GetFollowing(accountID string, limit int) (model.AccountList, e accounts := make([]model.Account, limit) if err := g.sendRequest(http.MethodGet, url, nil, &accounts); err != nil { - return model.AccountList{}, fmt.Errorf("received an error after sending the request to get the list of followed accounts; %w", err) + return model.AccountList{}, fmt.Errorf("received an error after sending the request to get the list of followed accounts: %w", err) } following := model.AccountList{ @@ -126,7 +126,7 @@ func (g *Client) BlockAccount(accountID string) error { url := g.Authentication.Instance + fmt.Sprintf("/api/v1/accounts/%s/block", accountID) if err := g.sendRequest(http.MethodPost, url, nil, nil); err != nil { - return fmt.Errorf("received an error after sending the request to block the account; %w", err) + return fmt.Errorf("received an error after sending the request to block the account: %w", err) } return nil @@ -136,7 +136,7 @@ func (g *Client) UnblockAccount(accountID string) error { url := g.Authentication.Instance + fmt.Sprintf("/api/v1/accounts/%s/unblock", accountID) if err := g.sendRequest(http.MethodPost, url, nil, nil); err != nil { - return fmt.Errorf("received an error after sending the request to unblock the account; %w", err) + return fmt.Errorf("received an error after sending the request to unblock the account: %w", err) } return nil @@ -148,7 +148,7 @@ func (g *Client) GetBlockedAccounts(limit int) (model.AccountList, error) { accounts := make([]model.Account, limit) if err := g.sendRequest(http.MethodGet, url, nil, &accounts); err != nil { - return model.AccountList{}, fmt.Errorf("received an error after sending the request to get the list of blocked accounts; %w", err) + return model.AccountList{}, fmt.Errorf("received an error after sending the request to get the list of blocked accounts: %w", err) } blocked := model.AccountList{ @@ -168,14 +168,14 @@ func (g *Client) SetPrivateNote(accountID, note string) error { data, err := json.Marshal(form) if err != nil { - return fmt.Errorf("unable to marshal the form; %w", err) + return fmt.Errorf("unable to marshal the form: %w", err) } requestBody := bytes.NewBuffer(data) url := g.Authentication.Instance + fmt.Sprintf("/api/v1/accounts/%s/note", accountID) if err := g.sendRequest(http.MethodPost, url, requestBody, nil); err != nil { - return fmt.Errorf("received an error after sending the request to set the private note; %w", err) + return fmt.Errorf("received an error after sending the request to set the private note: %w", err) } return nil diff --git a/internal/client/client.go b/internal/client/client.go index 14727ff..ea006e7 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -27,7 +27,7 @@ type Client struct { func NewClientFromConfig(configDir string) (*Client, error) { config, err := config.NewCredentialsConfigFromFile(configDir) if err != nil { - return nil, fmt.Errorf("unable to get the authentication configuration; %w", err) + return nil, fmt.Errorf("unable to get the authentication configuration: %w", err) } currentAuthentication := config.Credentials[config.CurrentAccount] @@ -79,14 +79,14 @@ func (g *Client) sendRequest(method string, url string, requestBody io.Reader, o response, err := g.HTTPClient.Do(request) if err != nil { - return fmt.Errorf("received an error after sending the request; %w", err) + return fmt.Errorf("received an error after sending the request: %w", err) } defer response.Body.Close() if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusBadRequest { return fmt.Errorf( - "did not receive an OK response from the GoToSocial server; got %d", + "did not receive an OK response from the GoToSocial server: got %d", response.StatusCode, ) } @@ -97,7 +97,7 @@ func (g *Client) sendRequest(method string, url string, requestBody io.Reader, o if err := json.NewDecoder(response.Body).Decode(object); err != nil { return fmt.Errorf( - "unable to decode the response from the GoToSocial server; %w", + "unable to decode the response from the GoToSocial server: %w", err, ) } diff --git a/internal/client/instance.go b/internal/client/instance.go index 03bf530..de531cf 100644 --- a/internal/client/instance.go +++ b/internal/client/instance.go @@ -18,7 +18,7 @@ func (g *Client) GetInstance() (model.InstanceV2, error) { var instance model.InstanceV2 if err := g.sendRequest(http.MethodGet, url, nil, &instance); err != nil { - return model.InstanceV2{}, fmt.Errorf("received an error after sending the request to get the instance details; %w", err) + return model.InstanceV2{}, fmt.Errorf("received an error after sending the request to get the instance details: %w", err) } return instance, nil diff --git a/internal/client/lists.go b/internal/client/lists.go index 0bb4d72..b46e22a 100644 --- a/internal/client/lists.go +++ b/internal/client/lists.go @@ -24,7 +24,7 @@ func (g *Client) GetAllLists() (model.Lists, error) { if err := g.sendRequest(http.MethodGet, url, nil, &lists); err != nil { return nil, fmt.Errorf( - "received an error after sending the request to get the list of lists; %w", + "received an error after sending the request to get the list of lists: %w", err, ) } @@ -39,7 +39,7 @@ func (g *Client) GetList(listID string) (model.List, error) { if err := g.sendRequest(http.MethodGet, url, nil, &list); err != nil { return model.List{}, fmt.Errorf( - "received an error after sending the request to get the list; %w", + "received an error after sending the request to get the list: %w", err, ) } @@ -55,7 +55,7 @@ type CreateListForm struct { func (g *Client) CreateList(form CreateListForm) (model.List, error) { data, err := json.Marshal(form) if err != nil { - return model.List{}, fmt.Errorf("unable to marshal the form; %w", err) + return model.List{}, fmt.Errorf("unable to marshal the form: %w", err) } requestBody := bytes.NewBuffer(data) @@ -65,7 +65,7 @@ func (g *Client) CreateList(form CreateListForm) (model.List, error) { if err := g.sendRequest(http.MethodPost, url, requestBody, &list); err != nil { return model.List{}, fmt.Errorf( - "received an error after sending the request to create the list; %w", + "received an error after sending the request to create the list: %w", err, ) } @@ -84,7 +84,7 @@ func (g *Client) UpdateList(listToUpdate model.List) (model.List, error) { data, err := json.Marshal(form) if err != nil { - return model.List{}, fmt.Errorf("unable to marshal the form; %w", err) + return model.List{}, fmt.Errorf("unable to marshal the form: %w", err) } requestBody := bytes.NewBuffer(data) @@ -94,7 +94,7 @@ func (g *Client) UpdateList(listToUpdate model.List) (model.List, error) { if err := g.sendRequest(http.MethodPut, url, requestBody, &updatedList); err != nil { return model.List{}, fmt.Errorf( - "received an error after sending the request to update the list; %w", + "received an error after sending the request to update the list: %w", err, ) } @@ -117,7 +117,7 @@ func (g *Client) AddAccountsToList(listID string, accountIDs []string) error { data, err := json.Marshal(form) if err != nil { - return fmt.Errorf("unable to marshal the form; %w", err) + return fmt.Errorf("unable to marshal the form: %w", err) } requestBody := bytes.NewBuffer(data) @@ -125,7 +125,7 @@ func (g *Client) AddAccountsToList(listID string, accountIDs []string) error { if err := g.sendRequest(http.MethodPost, url, requestBody, nil); err != nil { return fmt.Errorf( - "received an error after sending the request to add the accounts to the list; %w", + "received an error after sending the request to add the accounts to the list: %w", err, ) } @@ -142,7 +142,7 @@ func (g *Client) RemoveAccountsFromList(listID string, accountIDs []string) erro data, err := json.Marshal(form) if err != nil { - return fmt.Errorf("unable to marshal the form; %w", err) + return fmt.Errorf("unable to marshal the form: %w", err) } requestBody := bytes.NewBuffer(data) @@ -150,7 +150,7 @@ func (g *Client) RemoveAccountsFromList(listID string, accountIDs []string) erro if err := g.sendRequest(http.MethodDelete, url, requestBody, nil); err != nil { return fmt.Errorf( - "received an error after sending the request to remove the accounts from the list; %w", + "received an error after sending the request to remove the accounts from the list: %w", err, ) } @@ -166,7 +166,7 @@ func (g *Client) GetAccountsFromList(listID string, limit int) ([]model.Account, if err := g.sendRequest(http.MethodGet, url, nil, &accounts); err != nil { return nil, fmt.Errorf( - "received an error after sending the request to get the accounts from the list; %w", + "received an error after sending the request to get the accounts from the list: %w", err, ) } diff --git a/internal/client/preferences.go b/internal/client/preferences.go index 11a5eb2..a424344 100644 --- a/internal/client/preferences.go +++ b/internal/client/preferences.go @@ -17,7 +17,7 @@ func (g *Client) GetUserPreferences() (model.Preferences, error) { var preferences model.Preferences if err := g.sendRequest(http.MethodGet, url, nil, &preferences); err != nil { - return model.Preferences{}, fmt.Errorf("received an error after sending the request to get the user preferences; %w", err) + return model.Preferences{}, fmt.Errorf("received an error after sending the request to get the user preferences: %w", err) } return preferences, nil diff --git a/internal/client/register.go b/internal/client/register.go index 38ae833..3800b3a 100644 --- a/internal/client/register.go +++ b/internal/client/register.go @@ -31,7 +31,7 @@ func (g *Client) Register() error { data, err := json.Marshal(params) if err != nil { - return fmt.Errorf("unable to marshal the request body; %w", err) + return fmt.Errorf("unable to marshal the request body: %w", err) } requestBody := bytes.NewBuffer(data) @@ -40,7 +40,7 @@ func (g *Client) Register() error { var app model.Application if err := g.sendRequest(http.MethodPost, url, requestBody, &app); err != nil { - return fmt.Errorf("received an error after sending the registration request; %w", err) + return fmt.Errorf("received an error after sending the registration request: %w", err) } g.Authentication.ClientID = app.ClientID diff --git a/internal/client/statuses.go b/internal/client/statuses.go index dcc515c..30a1086 100644 --- a/internal/client/statuses.go +++ b/internal/client/statuses.go @@ -21,7 +21,7 @@ func (g *Client) GetStatus(statusID string) (model.Status, error) { if err := g.sendRequest(http.MethodGet, url, nil, &status); err != nil { return model.Status{}, fmt.Errorf( - "received an error after sending the request to get the status information; %w", + "received an error after sending the request to get the status information: %w", err, ) } @@ -45,7 +45,7 @@ type CreateStatusForm struct { func (g *Client) CreateStatus(form CreateStatusForm) (model.Status, error) { data, err := json.Marshal(form) if err != nil { - return model.Status{}, fmt.Errorf("unable to create the JSON form; %w", err) + return model.Status{}, fmt.Errorf("unable to create the JSON form: %w", err) } requestBody := bytes.NewBuffer(data) @@ -55,7 +55,7 @@ func (g *Client) CreateStatus(form CreateStatusForm) (model.Status, error) { if err := g.sendRequest(http.MethodPost, url, requestBody, &status); err != nil { return model.Status{}, fmt.Errorf( - "received an error after sending the request to create the status; %w", + "received an error after sending the request to create the status: %w", err, ) } diff --git a/internal/client/timelines.go b/internal/client/timelines.go index aec5936..39b5c6a 100644 --- a/internal/client/timelines.go +++ b/internal/client/timelines.go @@ -61,7 +61,7 @@ func (g *Client) getTimeline(path string, timeline model.Timeline) (model.Timeli var statuses []model.Status if err := g.sendRequest(http.MethodGet, url, nil, &statuses); err != nil { - return timeline, fmt.Errorf("received an error after sending the request to get the timeline; %w", err) + return timeline, fmt.Errorf("received an error after sending the request to get the timeline: %w", err) } timeline.Statuses = statuses diff --git a/internal/client/token.go b/internal/client/token.go index 4cefd7c..ed8190d 100644 --- a/internal/client/token.go +++ b/internal/client/token.go @@ -42,7 +42,7 @@ func (g *Client) UpdateToken(code string) error { data, err := json.Marshal(params) if err != nil { - return fmt.Errorf("unable to marshal the request body; %w", err) + return fmt.Errorf("unable to marshal the request body: %w", err) } requestBody := bytes.NewBuffer(data) @@ -51,7 +51,7 @@ func (g *Client) UpdateToken(code string) error { var response tokenResponse if err := g.sendRequest(http.MethodPost, url, requestBody, &response); err != nil { - return fmt.Errorf("received an error after sending the token request; %w", err) + return fmt.Errorf("received an error after sending the token request: %w", err) } if response.AccessToken == "" { diff --git a/internal/config/credentials.go b/internal/config/credentials.go index 98e6761..56bb077 100644 --- a/internal/config/credentials.go +++ b/internal/config/credentials.go @@ -42,7 +42,7 @@ func (e CredentialsNotFoundError) Error() string { // is not present, it will be created. func SaveCredentials(configDir, username string, credentials Credentials) (string, error) { if err := ensureConfigDir(calculateConfigDir(configDir)); err != nil { - return "", fmt.Errorf("unable to ensure the configuration directory; %w", err) + return "", fmt.Errorf("unable to ensure the configuration directory: %w", err) } var authConfig CredentialsConfig @@ -51,14 +51,14 @@ func SaveCredentials(configDir, username string, credentials Credentials) (strin if _, err := os.Stat(filepath); err != nil { if !errors.Is(err, os.ErrNotExist) { - return "", fmt.Errorf("unknown error received when running stat on %s; %w", filepath, err) + return "", fmt.Errorf("unknown error received when running stat on %s: %w", filepath, err) } authConfig.Credentials = make(map[string]Credentials) } else { authConfig, err = NewCredentialsConfigFromFile(configDir) if err != nil { - return "", fmt.Errorf("unable to retrieve the existing authentication configuration; %w", err) + return "", fmt.Errorf("unable to retrieve the existing authentication configuration: %w", err) } } @@ -77,7 +77,7 @@ func SaveCredentials(configDir, username string, credentials Credentials) (strin authConfig.Credentials[authenticationName] = credentials if err := saveCredentialsConfigFile(authConfig, configDir); err != nil { - return "", fmt.Errorf("unable to save the authentication configuration to file; %w", err) + return "", fmt.Errorf("unable to save the authentication configuration to file: %w", err) } return authenticationName, nil @@ -86,7 +86,7 @@ func SaveCredentials(configDir, username string, credentials Credentials) (strin func UpdateCurrentAccount(account string, configDir string) error { credentialsConfig, err := NewCredentialsConfigFromFile(configDir) if err != nil { - return fmt.Errorf("unable to retrieve the existing authentication configuration; %w", err) + return fmt.Errorf("unable to retrieve the existing authentication configuration: %w", err) } if _, ok := credentialsConfig.Credentials[account]; !ok { @@ -96,7 +96,7 @@ func UpdateCurrentAccount(account string, configDir string) error { credentialsConfig.CurrentAccount = account if err := saveCredentialsConfigFile(credentialsConfig, configDir); err != nil { - return fmt.Errorf("unable to save the authentication configuration to file; %w", err) + return fmt.Errorf("unable to save the authentication configuration to file: %w", err) } return nil @@ -114,7 +114,7 @@ func NewCredentialsConfigFromFile(configDir string) (CredentialsConfig, error) { var authConfig CredentialsConfig if err := json.NewDecoder(file).Decode(&authConfig); err != nil { - return CredentialsConfig{}, fmt.Errorf("unable to decode the JSON data; %w", err) + return CredentialsConfig{}, fmt.Errorf("unable to decode the JSON data: %w", err) } return authConfig, nil @@ -125,7 +125,7 @@ func saveCredentialsConfigFile(authConfig CredentialsConfig, configDir string) e file, err := os.Create(path) if err != nil { - return fmt.Errorf("unable to open %s; %w", path, err) + return fmt.Errorf("unable to open %s: %w", path, err) } defer file.Close() @@ -134,7 +134,7 @@ func saveCredentialsConfigFile(authConfig CredentialsConfig, configDir string) e encoder.SetIndent("", " ") if err := encoder.Encode(authConfig); err != nil { - return fmt.Errorf("unable to save the JSON data to the authentication config file; %w", err) + return fmt.Errorf("unable to save the JSON data to the authentication config file: %w", err) } return nil diff --git a/internal/config/directory.go b/internal/config/directory.go index 8e691fa..4cad91b 100644 --- a/internal/config/directory.go +++ b/internal/config/directory.go @@ -30,10 +30,10 @@ func ensureConfigDir(configDir string) error { if _, err := os.Stat(configDir); err != nil { if errors.Is(err, os.ErrNotExist) { if err := os.MkdirAll(configDir, 0o750); err != nil { - return fmt.Errorf("unable to create %s; %w", configDir, err) + return fmt.Errorf("unable to create %s: %w", configDir, err) } } else { - return fmt.Errorf("unknown error received when running stat on %s; %w", configDir, err) + return fmt.Errorf("unknown error received after getting the config directory information: %w", err) } } diff --git a/internal/executor/account.go b/internal/executor/account.go index 5626f1a..0d2ec37 100644 --- a/internal/executor/account.go +++ b/internal/executor/account.go @@ -22,12 +22,12 @@ func getAccountID(gtsClient *client.Client, myAccount bool, accountName, configD case myAccount: accountID, err = getMyAccountID(gtsClient, configDir) if err != nil { - return "", fmt.Errorf("unable to get your account ID; %w", err) + return "", fmt.Errorf("unable to get your account ID: %w", err) } case accountName != "": accountID, err = getTheirAccountID(gtsClient, accountName) if err != nil { - return "", fmt.Errorf("unable to get their account ID; %w", err) + return "", fmt.Errorf("unable to get their account ID: %w", err) } default: return "", NoAccountSpecifiedError{} @@ -39,7 +39,7 @@ func getAccountID(gtsClient *client.Client, myAccount bool, accountName, configD func getTheirAccountID(gtsClient *client.Client, accountURI string) (string, error) { account, err := getAccount(gtsClient, accountURI) if err != nil { - return "", fmt.Errorf("unable to retrieve your account; %w", err) + return "", fmt.Errorf("unable to retrieve your account: %w", err) } return account.ID, nil @@ -48,7 +48,7 @@ func getTheirAccountID(gtsClient *client.Client, accountURI string) (string, err func getMyAccountID(gtsClient *client.Client, configDir string) (string, error) { account, err := getMyAccount(gtsClient, configDir) if err != nil { - return "", fmt.Errorf("received an error while getting your account details; %w", err) + return "", fmt.Errorf("received an error while getting your account details: %w", err) } return account.ID, nil @@ -57,14 +57,14 @@ func getMyAccountID(gtsClient *client.Client, configDir string) (string, error) func getMyAccount(gtsClient *client.Client, configDir string) (model.Account, error) { authConfig, err := config.NewCredentialsConfigFromFile(configDir) if err != nil { - return model.Account{}, fmt.Errorf("unable to retrieve the authentication configuration; %w", err) + return model.Account{}, fmt.Errorf("unable to retrieve the authentication configuration: %w", err) } accountURI := authConfig.CurrentAccount account, err := getAccount(gtsClient, accountURI) if err != nil { - return model.Account{}, fmt.Errorf("unable to retrieve your account; %w", err) + return model.Account{}, fmt.Errorf("unable to retrieve your account: %w", err) } return account, nil @@ -73,7 +73,7 @@ func getMyAccount(gtsClient *client.Client, configDir string) (model.Account, er func getAccount(gtsClient *client.Client, accountURI string) (model.Account, error) { account, err := gtsClient.GetAccount(accountURI) if err != nil { - return model.Account{}, fmt.Errorf("unable to retrieve the account details; %w", err) + return model.Account{}, fmt.Errorf("unable to retrieve the account details: %w", err) } return account, nil diff --git a/internal/executor/add.go b/internal/executor/add.go index 5bff1ab..567ef4d 100644 --- a/internal/executor/add.go +++ b/internal/executor/add.go @@ -59,7 +59,7 @@ func (a *AddExecutor) Execute() error { gtsClient, err := client.NewClientFromConfig(a.topLevelFlags.ConfigDir) if err != nil { - return fmt.Errorf("unable to create the GoToSocial client; %w", err) + return fmt.Errorf("unable to create the GoToSocial client: %w", err) } return doFunc(gtsClient) @@ -102,7 +102,7 @@ func (a *AddExecutor) addAccountsToList(gtsClient *client.Client) error { } if err := gtsClient.AddAccountsToList(a.listID, accountIDs); err != nil { - return fmt.Errorf("unable to add the accounts to the list; %w", err) + return fmt.Errorf("unable to add the accounts to the list: %w", err) } fmt.Println("Successfully added the account(s) to the list.") @@ -128,12 +128,12 @@ func (a *AddExecutor) addToAccount(gtsClient *client.Client) error { func (a *AddExecutor) addNoteToAccount(gtsClient *client.Client) error { if len(a.accountNames) != 1 { - return fmt.Errorf("unexpected number of accounts specified; want 1, got %d", len(a.accountNames)) + return fmt.Errorf("unexpected number of accounts specified: want 1, got %d", len(a.accountNames)) } accountID, err := getAccountID(gtsClient, false, a.accountNames[0], a.topLevelFlags.ConfigDir) if err != nil { - return fmt.Errorf("received an error while getting the account ID; %w", err) + return fmt.Errorf("received an error while getting the account ID: %w", err) } if a.content == "" { @@ -144,7 +144,7 @@ func (a *AddExecutor) addNoteToAccount(gtsClient *client.Client) error { } if err := gtsClient.SetPrivateNote(accountID, a.content); err != nil { - return fmt.Errorf("unable to add the private note to the account; %w", err) + return fmt.Errorf("unable to add the private note to the account: %w", err) } fmt.Println("Successfully added the private note to the account.") diff --git a/internal/executor/block.go b/internal/executor/block.go index b320816..89928c5 100644 --- a/internal/executor/block.go +++ b/internal/executor/block.go @@ -48,7 +48,7 @@ func (b *BlockExecutor) Execute() error { gtsClient, err := client.NewClientFromConfig(b.topLevelFlags.ConfigDir) if err != nil { - return fmt.Errorf("unable to create the GoToSocial client; %w", err) + return fmt.Errorf("unable to create the GoToSocial client: %w", err) } return doFunc(gtsClient) @@ -57,7 +57,7 @@ func (b *BlockExecutor) Execute() error { func (b *BlockExecutor) blockAccount(gtsClient *client.Client) error { accountID, err := getAccountID(gtsClient, false, b.accountName, b.topLevelFlags.ConfigDir) if err != nil { - return fmt.Errorf("received an error while getting the account ID; %w", err) + return fmt.Errorf("received an error while getting the account ID: %w", err) } if b.unblock { @@ -65,7 +65,7 @@ func (b *BlockExecutor) blockAccount(gtsClient *client.Client) error { } if err := gtsClient.BlockAccount(accountID); err != nil { - return fmt.Errorf("unable to block the account; %w", err) + return fmt.Errorf("unable to block the account: %w", err) } fmt.Println("Successfully blocked the account.") @@ -75,7 +75,7 @@ func (b *BlockExecutor) blockAccount(gtsClient *client.Client) error { func (b *BlockExecutor) unblockAccount(gtsClient *client.Client, accountID string) error { if err := gtsClient.UnblockAccount(accountID); err != nil { - return fmt.Errorf("unable to unblock the account; %w", err) + return fmt.Errorf("unable to unblock the account: %w", err) } fmt.Println("Successfully unblocked the account.") diff --git a/internal/executor/create.go b/internal/executor/create.go index a9eec1c..84c2793 100644 --- a/internal/executor/create.go +++ b/internal/executor/create.go @@ -112,7 +112,7 @@ func (c *CreateExecutor) createList(gtsClient *client.Client) error { list, err := gtsClient.CreateList(form) if err != nil { - return fmt.Errorf("unable to create the list; %w", err) + return fmt.Errorf("unable to create the list: %w", err) } fmt.Println("Successfully created the following list:") diff --git a/internal/executor/delete.go b/internal/executor/delete.go index 29617f3..2df8cdb 100644 --- a/internal/executor/delete.go +++ b/internal/executor/delete.go @@ -49,7 +49,7 @@ func (d *DeleteExecutor) Execute() error { gtsClient, err := client.NewClientFromConfig(d.topLevelFlags.ConfigDir) if err != nil { - return fmt.Errorf("unable to create the GoToSocial client; %w", err) + return fmt.Errorf("unable to create the GoToSocial client: %w", err) } return doFunc(gtsClient) @@ -61,7 +61,7 @@ func (d *DeleteExecutor) deleteList(gtsClient *client.Client) error { } if err := gtsClient.DeleteList(d.listID); err != nil { - return fmt.Errorf("unable to delete the list; %w", err) + return fmt.Errorf("unable to delete the list: %w", err) } fmt.Println("The list was successfully deleted.") diff --git a/internal/executor/edit.go b/internal/executor/edit.go index 82959fa..f21b233 100644 --- a/internal/executor/edit.go +++ b/internal/executor/edit.go @@ -55,7 +55,7 @@ func (e *EditExecutor) Execute() error { gtsClient, err := client.NewClientFromConfig(e.topLevelFlags.ConfigDir) if err != nil { - return fmt.Errorf("unable to create the GoToSocial client; %w", err) + return fmt.Errorf("unable to create the GoToSocial client: %w", err) } return doFunc(gtsClient) @@ -68,7 +68,7 @@ func (e *EditExecutor) editList(gtsClient *client.Client) error { list, err := gtsClient.GetList(e.listID) if err != nil { - return fmt.Errorf("unable to get the list; %w", err) + return fmt.Errorf("unable to get the list: %w", err) } if e.listTitle != "" { @@ -86,7 +86,7 @@ func (e *EditExecutor) editList(gtsClient *client.Client) error { updatedList, err := gtsClient.UpdateList(list) if err != nil { - return fmt.Errorf("unable to update the list; %w", err) + return fmt.Errorf("unable to update the list: %w", err) } fmt.Println("Successfully updated the list.") diff --git a/internal/executor/follow.go b/internal/executor/follow.go index 8116cd9..ea421dc 100644 --- a/internal/executor/follow.go +++ b/internal/executor/follow.go @@ -51,7 +51,7 @@ func (c *FollowExecutor) Execute() error { gtsClient, err := client.NewClientFromConfig(c.topLevelFlags.ConfigDir) if err != nil { - return fmt.Errorf("unable to create the GoToSocial client; %w", err) + return fmt.Errorf("unable to create the GoToSocial client: %w", err) } return doFunc(gtsClient) @@ -60,7 +60,7 @@ func (c *FollowExecutor) Execute() error { func (c *FollowExecutor) followAccount(gtsClient *client.Client) error { accountID, err := getAccountID(gtsClient, false, c.accountName, c.topLevelFlags.ConfigDir) if err != nil { - return fmt.Errorf("received an error while getting the account ID; %w", err) + return fmt.Errorf("received an error while getting the account ID: %w", err) } if c.unfollow { @@ -74,7 +74,7 @@ func (c *FollowExecutor) followAccount(gtsClient *client.Client) error { } if err := gtsClient.FollowAccount(form); err != nil { - return fmt.Errorf("unable to follow the account; %w", err) + return fmt.Errorf("unable to follow the account: %w", err) } fmt.Println("The follow request was sent successfully.") @@ -84,7 +84,7 @@ func (c *FollowExecutor) followAccount(gtsClient *client.Client) error { func (c *FollowExecutor) unfollowAccount(gtsClient *client.Client, accountID string) error { if err := gtsClient.UnfollowAccount(accountID); err != nil { - return fmt.Errorf("unable to unfollow the account; %w", err) + return fmt.Errorf("unable to unfollow the account: %w", err) } fmt.Println("Successfully unfollowed the account.") diff --git a/internal/executor/login.go b/internal/executor/login.go index ac3fc13..821a49c 100644 --- a/internal/executor/login.go +++ b/internal/executor/login.go @@ -59,7 +59,7 @@ func (c *LoginExecutor) Execute() error { gtsClient := client.NewClient(credentials) if err := gtsClient.Register(); err != nil { - return fmt.Errorf("unable to register the application; %w", err) + return fmt.Errorf("unable to register the application: %w", err) } consentPageURL := gtsClient.AuthCodeURL() @@ -83,21 +83,21 @@ Once you have the code please copy and paste it below. fmt.Print("Out-of-band token: ") if _, err := fmt.Scanln(&code); err != nil { - return fmt.Errorf("failed to read access code; %w", err) + return fmt.Errorf("failed to read access code: %w", err) } if err := gtsClient.UpdateToken(code); err != nil { - return fmt.Errorf("unable to update the client's access token; %w", err) + return fmt.Errorf("unable to update the client's access token: %w", err) } account, err := gtsClient.VerifyCredentials() if err != nil { - return fmt.Errorf("unable to verify the credentials; %w", err) + return fmt.Errorf("unable to verify the credentials: %w", err) } loginName, err := config.SaveCredentials(c.topLevelFlags.ConfigDir, account.Username, gtsClient.Authentication) if err != nil { - return fmt.Errorf("unable to save the authentication details; %w", err) + return fmt.Errorf("unable to save the authentication details: %w", err) } fmt.Printf("Successfully logged into %s\n", loginName) diff --git a/internal/executor/remove.go b/internal/executor/remove.go index 0e24fa8..16fd326 100644 --- a/internal/executor/remove.go +++ b/internal/executor/remove.go @@ -57,7 +57,7 @@ func (r *RemoveExecutor) Execute() error { gtsClient, err := client.NewClientFromConfig(r.topLevelFlags.ConfigDir) if err != nil { - return fmt.Errorf("unable to create the GoToSocial client; %w", err) + return fmt.Errorf("unable to create the GoToSocial client: %w", err) } return doFunc(gtsClient) @@ -100,7 +100,7 @@ func (r *RemoveExecutor) removeAccountsFromList(gtsClient *client.Client) error } if err := gtsClient.RemoveAccountsFromList(r.listID, accountIDs); err != nil { - return fmt.Errorf("unable to remove the accounts from the list; %w", err) + return fmt.Errorf("unable to remove the accounts from the list: %w", err) } fmt.Println("Successfully removed the account(s) from the list.") @@ -126,16 +126,16 @@ func (r *RemoveExecutor) removeFromAccount(gtsClient *client.Client) error { func (r *RemoveExecutor) removeNoteFromAccount(gtsClient *client.Client) error { if len(r.accountNames) != 1 { - return fmt.Errorf("unexpected number of accounts specified; want 1, got %d", len(r.accountNames)) + return fmt.Errorf("unexpected number of accounts specified: want 1, got %d", len(r.accountNames)) } accountID, err := getAccountID(gtsClient, false, r.accountNames[0], r.topLevelFlags.ConfigDir) if err != nil { - return fmt.Errorf("received an error while getting the account ID; %w", err) + return fmt.Errorf("received an error while getting the account ID: %w", err) } if err := gtsClient.SetPrivateNote(accountID, ""); err != nil { - return fmt.Errorf("unable to remove the private note from the account; %w", err) + return fmt.Errorf("unable to remove the private note from the account: %w", err) } fmt.Println("Successfully removed the private note from the account.") diff --git a/internal/executor/switch.go b/internal/executor/switch.go index 05f40df..5c85ac6 100644 --- a/internal/executor/switch.go +++ b/internal/executor/switch.go @@ -52,7 +52,7 @@ func (s *SwitchExecutor) switchToAccount() error { } if err := config.UpdateCurrentAccount(s.accountName, s.topLevelFlags.ConfigDir); err != nil { - return fmt.Errorf("unable to switch account to the account; %w", err) + return fmt.Errorf("unable to switch account to the account: %w", err) } fmt.Printf("The current account is now set to %q.\n", s.accountName) diff --git a/internal/executor/whoami.go b/internal/executor/whoami.go index 73345fd..8b87b3c 100644 --- a/internal/executor/whoami.go +++ b/internal/executor/whoami.go @@ -31,7 +31,7 @@ func NewWhoAmIExecutor(tlf TopLevelFlags, name, summary string) *WhoAmIExecutor func (c *WhoAmIExecutor) Execute() error { config, err := config.NewCredentialsConfigFromFile(c.topLevelFlags.ConfigDir) if err != nil { - return fmt.Errorf("unable to load the credential config; %w", err) + return fmt.Errorf("unable to load the credential config: %w", err) } fmt.Printf("You are logged in as %q.\n", config.CurrentAccount) diff --git a/internal/model/list.go b/internal/model/list.go index 30f3e48..6fb2ed6 100644 --- a/internal/model/list.go +++ b/internal/model/list.go @@ -77,7 +77,7 @@ func (l *ListRepliesPolicy) UnmarshalJSON(data []byte) error { ) if err = json.Unmarshal(data, &value); err != nil { - return fmt.Errorf("unable to decode the JSON data; %w", err) + return fmt.Errorf("unable to decode the JSON data: %w", err) } *l, err = ParseListRepliesPolicy(value) diff --git a/internal/model/status_visibility.go b/internal/model/status_visibility.go index 48c9262..b001427 100644 --- a/internal/model/status_visibility.go +++ b/internal/model/status_visibility.go @@ -83,7 +83,7 @@ func (s *StatusVisibility) UnmarshalJSON(data []byte) error { ) if err = json.Unmarshal(data, &value); err != nil { - return fmt.Errorf("unable to decode the JSON data; %w", err) + return fmt.Errorf("unable to decode the JSON data: %w", err) } // Ignore the error if the visibility from another service is diff --git a/internal/utilities/file.go b/internal/utilities/file.go index b35827d..99fc67b 100644 --- a/internal/utilities/file.go +++ b/internal/utilities/file.go @@ -12,7 +12,7 @@ import ( func ReadFile(path string) (string, error) { data, err := os.ReadFile(path) if err != nil { - return "", fmt.Errorf("unable to read the data from the file; %w", err) + return "", fmt.Errorf("unable to read the data from the file: %w", err) } return string(data), nil