Variable collisions; Possible use of nil value (#256)
* Variable '*' collides with imported package name * Variable 'error' collides with builtin interface * '*' may have 'nil' or other unexpected value as its corresponding error variable may be not 'nil'
This commit is contained in:
@@ -9,8 +9,8 @@ import (
|
||||
|
||||
// GetHardwareStats will return hardware utilization over time
|
||||
func GetHardwareStats(w http.ResponseWriter, r *http.Request) {
|
||||
metrics := metrics.Metrics
|
||||
m := metrics.Metrics
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(metrics)
|
||||
json.NewEncoder(w).Encode(m)
|
||||
}
|
||||
|
||||
@@ -15,13 +15,13 @@ import (
|
||||
|
||||
// Make this path configurable if somebody has a valid reason
|
||||
// to need it to be. The config is getting a bit bloated.
|
||||
const emojiPath = "/img/emoji" // Relative to webroot
|
||||
const emojiDir = "/img/emoji" // Relative to webroot
|
||||
|
||||
//GetCustomEmoji returns a list of custom emoji via the API
|
||||
func GetCustomEmoji(w http.ResponseWriter, r *http.Request) {
|
||||
emojiList := make([]models.CustomEmoji, 0)
|
||||
|
||||
fullPath := filepath.Join(config.WebRoot, emojiPath)
|
||||
fullPath := filepath.Join(config.WebRoot, emojiDir)
|
||||
files, err := ioutil.ReadDir(fullPath)
|
||||
if err != nil {
|
||||
log.Errorln(err)
|
||||
@@ -34,8 +34,8 @@ func GetCustomEmoji(w http.ResponseWriter, r *http.Request) {
|
||||
// the server to add emoji?
|
||||
for _, f := range files {
|
||||
name := strings.TrimSuffix(f.Name(), path.Ext(f.Name()))
|
||||
path := filepath.Join(emojiPath, f.Name())
|
||||
singleEmoji := models.CustomEmoji{name, path}
|
||||
emojiPath := filepath.Join(emojiDir, f.Name())
|
||||
singleEmoji := models.CustomEmoji{name, emojiPath}
|
||||
emojiList = append(emojiList, singleEmoji)
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,13 @@ func handleScraperMetadataPage(w http.ResponseWriter, r *http.Request) {
|
||||
tmpl := template.Must(template.ParseFiles(path.Join("static", "metadata.html")))
|
||||
|
||||
fullURL, err := url.Parse(fmt.Sprintf("http://%s%s", r.Host, r.URL.Path))
|
||||
if err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
imageURL, err := url.Parse(fmt.Sprintf("http://%s%s", r.Host, config.Config.InstanceDetails.Logo.Large))
|
||||
if err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
status := core.GetStatus()
|
||||
|
||||
@@ -74,8 +80,10 @@ func handleScraperMetadataPage(w http.ResponseWriter, r *http.Request) {
|
||||
thumbnail, err := url.Parse(fmt.Sprintf("http://%s%s", r.Host, "/thumbnail.jpg"))
|
||||
if err != nil {
|
||||
log.Errorln(err)
|
||||
thumbnailURL = imageURL.String()
|
||||
} else {
|
||||
thumbnailURL = thumbnail.String()
|
||||
}
|
||||
thumbnailURL = thumbnail.String()
|
||||
} else {
|
||||
thumbnailURL = imageURL.String()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user