mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
20191215 code improvements (#790)
* Upgrade godo to latest * Fix a bunch of issues found by * Running staticcheck on a codebase for the first time is a sobering experience * go mod tidy * More static improvements Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
@@ -64,7 +64,6 @@ type ItemLists struct {
|
||||
type request struct {
|
||||
requestBody interface{}
|
||||
method string
|
||||
result interface{}
|
||||
headers map[string]string
|
||||
url string
|
||||
}
|
||||
@@ -100,8 +99,8 @@ func (client *Client) request(req request, result interface{}) error {
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(responseBody, &result); err != nil {
|
||||
return fmt.Errorf("Could not unmarshal url [%s] \n\t\tresponse [%s] request[%s] error:%w",
|
||||
req.url, responseBody, jsonValues, err)
|
||||
return fmt.Errorf("could not unmarshal url [%s] \n\t\tresponse [%s] request[%s] error:%w",
|
||||
req.url, responseBody, jsonValues, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -120,13 +119,13 @@ func (client *Client) ObtainRequestToken() (code string, err error) {
|
||||
|
||||
var responseData map[string]string
|
||||
req := request{
|
||||
headers: map[string]string{
|
||||
"X-Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
method: "POST",
|
||||
url: url,
|
||||
requestBody: requestData,
|
||||
}
|
||||
req.headers = map[string]string{
|
||||
"X-Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
url: url,
|
||||
}
|
||||
err = client.request(req, &responseData)
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ func (widget *Widget) Refresh() {
|
||||
}
|
||||
|
||||
state := Unread
|
||||
if widget.archivedView == true {
|
||||
if widget.archivedView {
|
||||
state = Read
|
||||
}
|
||||
response, err := widget.client.GetLinks(state)
|
||||
@@ -84,7 +84,7 @@ func writeMetaDataToDisk(metaData pocketMetaData) error {
|
||||
|
||||
fileData, err := yaml.Marshal(metaData)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Could not write token to disk %w", err)
|
||||
return fmt.Errorf("could not write token to disk %w", err)
|
||||
}
|
||||
|
||||
wtfConfigDir, err := cfg.WtfConfigDir()
|
||||
@@ -187,7 +187,7 @@ func (widget *Widget) openLink() {
|
||||
func (widget *Widget) toggleLink() {
|
||||
sel := widget.GetSelected()
|
||||
action := Archive
|
||||
if widget.archivedView == true {
|
||||
if widget.archivedView {
|
||||
action = ReAdd
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ func (widget *Widget) toggleLink() {
|
||||
func (widget *Widget) formatItem(item Item, isSelected bool) string {
|
||||
foreColor, backColor := widget.settings.common.Colors.RowTheme.EvenForeground, widget.settings.common.Colors.RowTheme.EvenBackground
|
||||
text := item.ResolvedTitle
|
||||
if isSelected == true {
|
||||
if isSelected {
|
||||
foreColor = widget.settings.common.Colors.RowTheme.HighlightedForeground
|
||||
backColor = widget.settings.common.Colors.RowTheme.HighlightedBackground
|
||||
|
||||
@@ -217,7 +217,7 @@ func (widget *Widget) formatItem(item Item, isSelected bool) string {
|
||||
func (widget *Widget) content() (string, string, bool) {
|
||||
title := widget.CommonSettings().Title
|
||||
currentViewTitle := "Reading List"
|
||||
if widget.archivedView == true {
|
||||
if widget.archivedView {
|
||||
currentViewTitle = "Archived list"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user