mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 09:37:02 +00:00
Resolve linter errors exposed by fixed Makefile
- TravisCI didn't like "POSIX" ::= syntax
This commit is contained in:
@@ -2,13 +2,12 @@ language: go
|
|||||||
sudo: false
|
sudo: false
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- DEPLOY_WITH_MAJOR="1.9"
|
- DEPLOY_WITH_MAJOR="1.10"
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- go get github.com/golang/lint/golint
|
- go get github.com/golang/lint/golint
|
||||||
|
|
||||||
go:
|
go:
|
||||||
- 1.9.x
|
|
||||||
- "1.10"
|
- "1.10"
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
|
|||||||
6
Makefile
6
Makefile
@@ -1,11 +1,11 @@
|
|||||||
SHELL = /bin/sh
|
SHELL = /bin/sh
|
||||||
|
|
||||||
SRC ::= $(shell find . -type f -name '*.go' -not -path "./vendor/*")
|
SRC := $(shell find . -type f -name '*.go' -not -path "./vendor/*")
|
||||||
PKGS ::= $(shell go list ./... | grep -v /vendor/)
|
PKGS := $(shell go list ./... | grep -v /vendor/)
|
||||||
|
|
||||||
.PHONY: all build clean fmt lint simplify test
|
.PHONY: all build clean fmt lint simplify test
|
||||||
|
|
||||||
commands ::= client inbucket
|
commands = client inbucket
|
||||||
|
|
||||||
all: clean test lint build
|
all: clean test lint build
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ func openLogFile() error {
|
|||||||
var err error
|
var err error
|
||||||
logf, err = os.OpenFile(logfname, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666)
|
logf, err = os.OpenFile(logfname, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Failed to create %v: %v\n", logfname, err)
|
return fmt.Errorf("failed to create %v: %v", logfname, err)
|
||||||
}
|
}
|
||||||
golog.SetOutput(logf)
|
golog.SetOutput(logf)
|
||||||
Tracef("Opened new logfile")
|
Tracef("Opened new logfile")
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ type JSONMessageV1 struct {
|
|||||||
Attachments []*JSONMessageAttachmentV1 `json:"attachments"`
|
Attachments []*JSONMessageAttachmentV1 `json:"attachments"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// JSONMessageAttachmentV1 contains information about a MIME attachment
|
||||||
type JSONMessageAttachmentV1 struct {
|
type JSONMessageAttachmentV1 struct {
|
||||||
FileName string `json:"filename"`
|
FileName string `json:"filename"`
|
||||||
ContentType string `json:"content-type"`
|
ContentType string `json:"content-type"`
|
||||||
|
|||||||
@@ -144,6 +144,8 @@ func (ml *msgListener) Close() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MonitorAllMessagesV1 is a web handler which upgrades the connection to a websocket and notifies
|
||||||
|
// the client of all messages received.
|
||||||
func MonitorAllMessagesV1(
|
func MonitorAllMessagesV1(
|
||||||
w http.ResponseWriter, req *http.Request, ctx *web.Context) (err error) {
|
w http.ResponseWriter, req *http.Request, ctx *web.Context) (err error) {
|
||||||
// Upgrade to Websocket
|
// Upgrade to Websocket
|
||||||
@@ -167,6 +169,8 @@ func MonitorAllMessagesV1(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MonitorMailboxMessagesV1 is a web handler which upgrades the connection to a websocket and
|
||||||
|
// notifies the client of messages received by a particular mailbox.
|
||||||
func MonitorMailboxMessagesV1(
|
func MonitorMailboxMessagesV1(
|
||||||
w http.ResponseWriter, req *http.Request, ctx *web.Context) (err error) {
|
w http.ResponseWriter, req *http.Request, ctx *web.Context) (err error) {
|
||||||
name, err := stringutil.ParseMailboxName(ctx.Vars["name"])
|
name, err := stringutil.ParseMailboxName(ctx.Vars["name"])
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jhillyerd/enmime"
|
"github.com/jhillyerd/enmime"
|
||||||
"github.com/jhillyerd/inbucket/pkg/storage"
|
|
||||||
"github.com/jhillyerd/inbucket/pkg/log"
|
"github.com/jhillyerd/inbucket/pkg/log"
|
||||||
|
"github.com/jhillyerd/inbucket/pkg/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FileMessage implements Message and contains a little bit of data about a
|
// FileMessage implements Message and contains a little bit of data about a
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jhillyerd/inbucket/pkg/config"
|
"github.com/jhillyerd/inbucket/pkg/config"
|
||||||
"github.com/jhillyerd/inbucket/pkg/storage"
|
|
||||||
"github.com/jhillyerd/inbucket/pkg/log"
|
"github.com/jhillyerd/inbucket/pkg/log"
|
||||||
|
"github.com/jhillyerd/inbucket/pkg/storage"
|
||||||
"github.com/jhillyerd/inbucket/pkg/stringutil"
|
"github.com/jhillyerd/inbucket/pkg/stringutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -140,6 +140,7 @@ func (ds *FileDataStore) AllMailboxes() ([]datastore.Mailbox, error) {
|
|||||||
return mailboxes, nil
|
return mailboxes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LockFor returns the RWMutex for this mailbox, or an error.
|
||||||
func (ds *FileDataStore) LockFor(emailAddress string) (*sync.RWMutex, error) {
|
func (ds *FileDataStore) LockFor(emailAddress string) (*sync.RWMutex, error) {
|
||||||
name, err := stringutil.ParseMailboxName(emailAddress)
|
name, err := stringutil.ParseMailboxName(emailAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -5,8 +5,12 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// HashLock holds a fixed length array of mutexes. This approach allows concurrent mailbox
|
||||||
|
// access in most cases without requiring an infinite number of mutexes.
|
||||||
type HashLock [4096]sync.RWMutex
|
type HashLock [4096]sync.RWMutex
|
||||||
|
|
||||||
|
// Get returns a RWMutex based on the first 12 bits of the mailbox hash. Hash must be a hexidecimal
|
||||||
|
// string of three or more characters.
|
||||||
func (h *HashLock) Get(hash string) *sync.RWMutex {
|
func (h *HashLock) Get(hash string) *sync.RWMutex {
|
||||||
if len(hash) < 3 {
|
if len(hash) < 3 {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ func (m *MockDataStore) AllMailboxes() ([]Mailbox, error) {
|
|||||||
return args.Get(0).([]Mailbox), args.Error(1)
|
return args.Get(0).([]Mailbox), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LockFor mock function returns a new RWMutex, never errors.
|
||||||
func (m *MockDataStore) LockFor(name string) (*sync.RWMutex, error) {
|
func (m *MockDataStore) LockFor(name string) (*sync.RWMutex, error) {
|
||||||
return &sync.RWMutex{}, nil
|
return &sync.RWMutex{}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ var (
|
|||||||
AllowAttrs("style").Matching(cssSafe).Globally()
|
AllowAttrs("style").Matching(cssSafe).Globally()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// HTML sanitizes the provided html, while attempting to preserve inline CSS styling.
|
||||||
func HTML(html string) (output string, err error) {
|
func HTML(html string) (output string, err error) {
|
||||||
output, err = sanitizeStyleTags(html)
|
output, err = sanitizeStyleTags(html)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user