Run go fmt
It has some Opinions on my code. Mostly whitespace and organizing the ordering of my structs.main
parent
bbdc5325ae
commit
cc4913d573
44
main.go
44
main.go
|
@ -18,42 +18,42 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
|
||||||
"net/url"
|
|
||||||
"net/http"
|
|
||||||
"time"
|
|
||||||
"context"
|
"context"
|
||||||
"html/template"
|
"html/template"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"time"
|
||||||
|
|
||||||
"path"
|
|
||||||
"os"
|
|
||||||
"mime/multipart"
|
|
||||||
"io"
|
"io"
|
||||||
|
"mime/multipart"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
|
||||||
"fmt"
|
|
||||||
"flag"
|
|
||||||
"errors"
|
"errors"
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
"github.com/mdp/qrterminal"
|
"github.com/mdp/qrterminal"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config stores all settings for an instance of RUFF.
|
// Config stores all settings for an instance of RUFF.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Downloads int
|
Downloads int
|
||||||
Port int
|
Port int
|
||||||
FilePath string
|
FilePath string
|
||||||
FileName string
|
FileName string
|
||||||
HideQR bool
|
HideQR bool
|
||||||
Uploading bool
|
Uploading bool
|
||||||
Multiple bool
|
Multiple bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func getConfig() (Config, error) {
|
func getConfig() (Config, error) {
|
||||||
conf := Config{
|
conf := Config{
|
||||||
Downloads: 1,
|
Downloads: 1,
|
||||||
Port: 8008,
|
Port: 8008,
|
||||||
HideQR: false,
|
HideQR: false,
|
||||||
Uploading: false,
|
Uploading: false,
|
||||||
Multiple: true,
|
Multiple: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
flag.IntVar(&conf.Downloads, "count", conf.Downloads, "number of downloads before exiting. set to -1 for unlimited downloads.")
|
flag.IntVar(&conf.Downloads, "count", conf.Downloads, "number of downloads before exiting. set to -1 for unlimited downloads.")
|
||||||
|
@ -103,9 +103,9 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
server := &http.Server{
|
server := &http.Server{
|
||||||
Addr: fmt.Sprintf(":%v", conf.Port),
|
Addr: fmt.Sprintf(":%v", conf.Port),
|
||||||
ReadTimeout: 10*time.Second,
|
ReadTimeout: 10 * time.Second,
|
||||||
WriteTimeout: 10*time.Second,
|
WriteTimeout: 10 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
if conf.Uploading {
|
if conf.Uploading {
|
||||||
|
@ -137,8 +137,8 @@ func main() {
|
||||||
|
|
||||||
// Wait for the server to finish any transfers, up to 3 seconds
|
// Wait for the server to finish any transfers, up to 3 seconds
|
||||||
select {
|
select {
|
||||||
case <-done:
|
case <-done:
|
||||||
case <-time.After(3*time.Second):
|
case <-time.After(3 * time.Second):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue