Browse Source

Fixed couple of warnings found with golint.

pull/28/merge
Simon Eisenmann 11 years ago
parent
commit
a8a6022e8c
  1. 1
      src/app/spreed-speakfreely-server/api.go
  2. 1
      src/app/spreed-speakfreely-server/buffercache.go
  3. 1
      src/app/spreed-speakfreely-server/config.go
  4. 1
      src/app/spreed-speakfreely-server/connection.go
  5. 1
      src/app/spreed-speakfreely-server/context.go
  6. 7
      src/app/spreed-speakfreely-server/hub.go
  7. 23
      src/app/spreed-speakfreely-server/images.go
  8. 10
      src/app/spreed-speakfreely-server/main.go
  9. 1
      src/app/spreed-speakfreely-server/random.go
  10. 1
      src/app/spreed-speakfreely-server/rooms.go
  11. 1
      src/app/spreed-speakfreely-server/roomworker.go
  12. 1
      src/app/spreed-speakfreely-server/server.go
  13. 1
      src/app/spreed-speakfreely-server/stats.go
  14. 18
      src/app/spreed-speakfreely-server/tokenprovider.go
  15. 1
      src/app/spreed-speakfreely-server/tokens.go
  16. 1
      src/app/spreed-speakfreely-server/user.go
  17. 1
      src/app/spreed-speakfreely-server/ws.go
  18. 1
      src/app/spreed-speakfreely-server/wsdata.go

1
src/app/spreed-speakfreely-server/api.go

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package main
import ()

1
src/app/spreed-speakfreely-server/buffercache.go

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package main
import (

1
src/app/spreed-speakfreely-server/config.go

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package main
import (

1
src/app/spreed-speakfreely-server/connection.go

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package main
import (

1
src/app/spreed-speakfreely-server/context.go

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package main
type Context struct {

7
src/app/spreed-speakfreely-server/hub.go

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package main
import (
@ -113,7 +114,7 @@ func (h *Hub) Stat(details bool) *HubStat { @@ -113,7 +114,7 @@ func (h *Hub) Stat(details bool) *HubStat {
rooms := make(map[string][]string)
for roomid, room := range h.roomTable {
users := make([]string, 0, len(room.connections))
for id, _ := range room.connections {
for id := range room.connections {
users = append(users, id)
}
rooms[roomid] = users
@ -215,9 +216,9 @@ func (h *Hub) GetGlobalConnections() []*Connection { @@ -215,9 +216,9 @@ func (h *Hub) GetGlobalConnections() []*Connection {
if room, ok := h.roomTable[h.config.globalRoomid]; ok {
h.mutex.RUnlock()
return room.GetConnections()
} else {
h.mutex.RUnlock()
}
h.mutex.RUnlock()
return make([]*Connection, 0)
}

23
src/app/spreed-speakfreely-server/images.go

@ -1,3 +1,24 @@ @@ -1,3 +1,24 @@
/*
* Spreed Speak Freely.
* Copyright (C) 2013-2014 struktur AG
*
* This file is part of Spreed Speak Freely.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package main
import (
@ -51,7 +72,7 @@ func NewImageCache() ImageCache { @@ -51,7 +72,7 @@ func NewImageCache() ImageCache {
}
func (self *imageCache) Update(userId string, image string) string {
var mimetype string = "image/x-unknown"
mimetype := "image/x-unknown"
pos := strings.Index(image, ";")
if pos != -1 {
mimetype = image[:pos]

10
src/app/spreed-speakfreely-server/main.go

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package main
import (
@ -49,12 +50,12 @@ var templates *template.Template @@ -49,12 +50,12 @@ var templates *template.Template
var config *Config
// Helper to retrieve languages from request.
func getRequestLanguages(r *http.Request, supported_languages []string) []string {
func getRequestLanguages(r *http.Request, supportedLanguages []string) []string {
accept_language_header, ok := r.Header["Accept-Language"]
acceptLanguageHeader, ok := r.Header["Accept-Language"]
var langs []string
if ok {
langs = goacceptlanguageparser.ParseAcceptLanguage(accept_language_header[0], supported_languages)
langs = goacceptlanguageparser.ParseAcceptLanguage(acceptLanguageHeader[0], supportedLanguages)
}
return langs
@ -290,9 +291,8 @@ func runner(runtime phoenix.Runtime) error { @@ -290,9 +291,8 @@ func runner(runtime phoenix.Runtime) error {
templates, err = templates.ParseGlob(path.Join(extraFolder, "*.html"))
if err != nil {
return fmt.Errorf("Failed to load extra templates: %s", err)
} else {
log.Printf("Loaded extra templates from: %s", extraFolder)
}
log.Printf("Loaded extra templates from: %s", extraFolder)
}
// Create our hub instance.

1
src/app/spreed-speakfreely-server/random.go

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package main
import (

1
src/app/spreed-speakfreely-server/rooms.go

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package main
import (

1
src/app/spreed-speakfreely-server/roomworker.go

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package main
import (

1
src/app/spreed-speakfreely-server/server.go

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package main
import (

1
src/app/spreed-speakfreely-server/stats.go

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package main
import (

18
src/app/spreed-speakfreely-server/tokenprovider.go

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package main
import (
@ -49,19 +50,19 @@ func (tf *TokenFile) ReloadIfModified() error { @@ -49,19 +50,19 @@ func (tf *TokenFile) ReloadIfModified() error {
return nil
}
func reload_tokens(tf *TokenFile) {
func reloadRokens(tf *TokenFile) {
r, err := os.Open(tf.Path)
if err != nil {
panic(err)
}
csv_reader := csv.NewReader(r)
csv_reader.Comma = ':'
csv_reader.Comment = '#'
csv_reader.TrimLeadingSpace = true
csvReader := csv.NewReader(r)
csvReader.Comma = ':'
csvReader.Comment = '#'
csvReader.TrimLeadingSpace = true
records, err := csv_reader.ReadAll()
records, err := csvReader.ReadAll()
if err != nil {
panic(err)
}
@ -76,15 +77,14 @@ func reload_tokens(tf *TokenFile) { @@ -76,15 +77,14 @@ func reload_tokens(tf *TokenFile) {
func TokenFileProvider(filename string) TokenProvider {
tf := &TokenFile{Path: filename}
tf.Reload = func() { reload_tokens(tf) }
tf.Reload = func() { reloadRokens(tf) }
return func(token string) string {
tf.ReloadIfModified()
_, exists := tf.Tokens[token]
if !exists {
return ""
} else {
return token
}
return token
}
}

1
src/app/spreed-speakfreely-server/tokens.go

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package main
import (

1
src/app/spreed-speakfreely-server/user.go

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package main
import (

1
src/app/spreed-speakfreely-server/ws.go

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package main
import (

1
src/app/spreed-speakfreely-server/wsdata.go

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package main
type DataHello struct {

Loading…
Cancel
Save