diff --git a/apbtime/time.go b/apbtime/time.go index 5b82fcff6687bf3afbb9c1edd2903f9a0a1f6c2a..461da072e6cca981f7c02ebaf063334c03322878 100644 --- a/apbtime/time.go +++ b/apbtime/time.go @@ -1,6 +1,7 @@ package apbtime import ( + "log" "strings" "time" ) @@ -19,7 +20,7 @@ func GetFormat() string { func GetLocation() *time.Location { loc, err := time.LoadLocation("Europe/Berlin") if err != nil { - panic(err) + log.Fatal(err) } return loc } diff --git a/clear.go b/clear.go index c6ec1069e4afcb4165fad96bf9e8be182e0a82dc..02377cec2e3b11ffc651c1071217b0127a78c811 100644 --- a/clear.go +++ b/clear.go @@ -10,11 +10,11 @@ import ( "git.rwth-aachen.de/h/apb/structs" ) -// This function panics because it is only called on initialising the semesterEndDates. +// This function log.Fatals because it is only called on initialising the semesterEndDates. func toTime(semesterEndDate string) time.Time { t, err := time.ParseInLocation("January 2, 2006", semesterEndDate, apbtime.GetLocation()) if err != nil { - panic(err) + log.Fatal(err) } return t } diff --git a/confirm.go b/confirm.go index 7794839c15c5474f99d93854bb9e72ce58667e85..7e9826dfa3ed11f13509367873c40ccb4f10a600 100644 --- a/confirm.go +++ b/confirm.go @@ -47,8 +47,8 @@ func (c confirmationMap) putNewEntry(conf confirmation) { r := strconv.Itoa(rand.Int()) c[r] = conf saveConfirmations(confirmationsPath) - mail.Send(conf.Email, "Email bestätigen", - "Hey, bitte bestätige deine Email: "+mail.URL+"confirm?id="+r) + log.Println(mail.Send(conf.Email, "Email bestätigen", + "Hey, bitte bestätige deine Email: "+mail.URL+"confirm?id="+r)) } func confirm(w http.ResponseWriter, r *http.Request) error { diff --git a/functions.go b/functions.go index 9134a7211162faa133bc8ce9696b3b8e112bd1b9..40a1ff302ae736f877147aeb44228291dda8fb98 100644 --- a/functions.go +++ b/functions.go @@ -3,7 +3,6 @@ package main import ( "encoding/json" "html/template" - "log" "net/http" "unicode/utf8" @@ -95,7 +94,6 @@ func respond(w http.ResponseWriter, r *http.Request) error { return renderError("Email-ID leer (hast du den DOM verändert?)", w, r) } to, err := mail.GetEmail(id) - log.Println(to) if err != nil { return err } diff --git a/go.mod b/go.mod index 59d8e669bd9d279ed670acf210f277e3221ed033..d85a24aca59734a0fda01714af52047796f41e3f 100644 --- a/go.mod +++ b/go.mod @@ -1,29 +1,5 @@ module git.rwth-aachen.de/h/apb -require ( - 4d63.com/gochecknoglobals v0.0.0-20180908201037-5090db600a84 // indirect - 4d63.com/gochecknoinits v0.0.0-20180528051558-14d5915061e5 // indirect - github.com/BurntSushi/toml v0.3.1 - github.com/alecthomas/gocyclo v0.0.0-20150208221726-aa8f8b160214 // indirect - github.com/alexflint/go-arg v0.0.0-20181120184500-fb7d95b61ba8 // indirect - github.com/alexflint/go-scalar v1.0.0 // indirect - github.com/alexkohler/nakedret v0.0.0-20171106223215-c0e305a4f690 // indirect - github.com/client9/misspell v0.3.4 // indirect - github.com/golang/lint v0.0.0-20181026193005-c67002cb31c3 // indirect - github.com/gordonklaus/ineffassign v0.0.0-20180909121442-1003c8bd00dc // indirect - github.com/jgautheron/goconst v0.0.0-20170703170152-9740945f5dcb // indirect - github.com/kisielk/errcheck v1.1.0 // indirect - github.com/mdempsky/maligned v0.0.0-20180708014732-6e39bd26a8c8 // indirect - github.com/mdempsky/unconvert v0.0.0-20180703203632-1a9a0a0a3594 // indirect - github.com/mibk/dupl v1.0.0 // indirect - github.com/opennota/check v0.0.0-20180911053232-0c771f5545ff // indirect - github.com/securego/gosec v0.0.0-20181111085728-2695567487c0 // indirect - github.com/stripe/safesql v0.0.0-20171221195208-cddf355596fe // indirect - github.com/tsenart/deadcode v0.0.0-20160724212837-210d2dc333e9 // indirect - github.com/walle/lll v0.0.0-20160702150637-8b13b3fbf731 // indirect - golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3 // indirect - honnef.co/go/tools v0.0.0-20180920025451-e3ad64cb4ed3 // indirect - mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed // indirect - mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b // indirect - mvdan.cc/unparam v0.0.0-20181201214637-68701730a1d7 // indirect -) +go 1.12 + +require github.com/BurntSushi/toml v0.3.1 diff --git a/go.sum b/go.sum index 34197c5b27828d068762f80c968190e441cb94e2..9cb2df8e75b21298dd12d346d3e8cd19364fd80e 100644 --- a/go.sum +++ b/go.sum @@ -1,79 +1,2 @@ -4d63.com/gochecknoglobals v0.0.0-20180908201037-5090db600a84 h1:OeDaqU4G+4jB1qoyr91IvkB6TN6FcdMn0h/kFn4BtEo= -4d63.com/gochecknoglobals v0.0.0-20180908201037-5090db600a84/go.mod h1:Sk40JNJmh0koZukOjJfaBNLZazbZthFfHnLHIcZNS6A= -4d63.com/gochecknoinits v0.0.0-20180528051558-14d5915061e5 h1:h34Nn8nf6uCkNqOnLH2SVsxaFOjhMkhaVWcMCDFb4RU= -4d63.com/gochecknoinits v0.0.0-20180528051558-14d5915061e5/go.mod h1:4o1i5aXtIF5tJFt3UD1knCVmWOXg7fLYdHVu6jeNcnM= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/alecthomas/gocyclo v0.0.0-20150208221726-aa8f8b160214 h1:YI/8G3uLbYyowJeOPVL6BMKe2wbL54h0FdEKmncU6lU= -github.com/alecthomas/gocyclo v0.0.0-20150208221726-aa8f8b160214/go.mod h1:Ef5UOtJdJ5rVFObdOVsrNgKV/Wf4I+daTCSk8GTrHIk= -github.com/alexflint/go-arg v0.0.0-20181120184500-fb7d95b61ba8 h1:kdVtd09Pmk4YpGHiQmx82Uql3pRJ0btcfSI6xG5LGiI= -github.com/alexflint/go-arg v0.0.0-20181120184500-fb7d95b61ba8/go.mod h1:PHxo6ZWOLVMZZgWSAqBynb/KhIqoGO6WKwOVX7rM9dg= -github.com/alexflint/go-scalar v1.0.0 h1:NGupf1XV/Xb04wXskDFzS0KWOLH632W/EO4fAFi+A70= -github.com/alexflint/go-scalar v1.0.0/go.mod h1:GpHzbCOZXEKMEcygYQ5n/aa4Aq84zbxjy3MxYW0gjYw= -github.com/alexkohler/nakedret v0.0.0-20171106223215-c0e305a4f690 h1:+tfdYWf4oDrj9c0/77f5oDBxZT2EPjS1AJf+PApGNCk= -github.com/alexkohler/nakedret v0.0.0-20171106223215-c0e305a4f690/go.mod h1:tfDQbtPt67HhBK/6P0yNktIX7peCxfOp0jO9007DrLE= -github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/golang/lint v0.0.0-20181026193005-c67002cb31c3 h1:I4BOK3PBMjhWfQM2zPJKK7lOBGsrsvOB7kBELP33hiE= -github.com/golang/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/gordonklaus/ineffassign v0.0.0-20180909121442-1003c8bd00dc h1:cJlkeAx1QYgO5N80aF5xRGstVsRQwgLR7uA2FnP1ZjY= -github.com/gordonklaus/ineffassign v0.0.0-20180909121442-1003c8bd00dc/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= -github.com/jgautheron/goconst v0.0.0-20170703170152-9740945f5dcb h1:D5s1HIu80AcMGcqmk7fNIVptmAubVHHaj3v5Upex6Zs= -github.com/jgautheron/goconst v0.0.0-20170703170152-9740945f5dcb/go.mod h1:82TxjOpWQiPmywlbIaB2ZkqJoSYJdLGPgAJDvM3PbKc= -github.com/kisielk/errcheck v1.1.0 h1:ZqfnKyx9KGpRcW04j5nnPDgRgoXUeLh2YFBeFzphcA0= -github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= -github.com/kisielk/gotool v0.0.0-20161130080628-0de1eaf82fa3/go.mod h1:jxZFDH7ILpTPQTk+E2s+z4CUas9lVNjIuKR4c5/zKgM= -github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/mdempsky/maligned v0.0.0-20180708014732-6e39bd26a8c8 h1:zvpKif6gkrh82wAd2JIffdLyCL52N8r+ABwHxdIOvWM= -github.com/mdempsky/maligned v0.0.0-20180708014732-6e39bd26a8c8/go.mod h1:oGVD62YTpMEWw0JqJ2Vl48dzHywJBMlapkfsmhtokOU= -github.com/mdempsky/unconvert v0.0.0-20180703203632-1a9a0a0a3594 h1:nh6s8K+g3tYL3vh8OXTC0f8r+R3tIS9PtXzTMgdpl30= -github.com/mdempsky/unconvert v0.0.0-20180703203632-1a9a0a0a3594/go.mod h1:G+0b7u4CERC4XI25lR40h0NhLMGQkht7QKGqzh45VoY= -github.com/mibk/dupl v1.0.0 h1:aZc3jqrF9n0tUHwHt/+jsRxA8cRgA0Gdl56M7W7PoqE= -github.com/mibk/dupl v1.0.0/go.mod h1:pCr4pNxxIbFGvtyCOi0c7LVjmV6duhKWV+ex5vh38ME= -github.com/mozilla/tls-observatory v0.0.0-20180409132520-8791a200eb40/go.mod h1:SrKMQvPiws7F7iqYp8/TX+IhxCYhzr6N/1yb8cwHsGk= -github.com/nbutton23/zxcvbn-go v0.0.0-20160627004424-a22cb81b2ecd h1:hEzcdYzgmGA1zDrSYdh+OE4H43RrglXdZQ5ip/+93GU= -github.com/nbutton23/zxcvbn-go v0.0.0-20160627004424-a22cb81b2ecd/go.mod h1:o96djdrsSGy3AWPyBgZMAGfxZNfgntdJG+11KU4QvbU= -github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= -github.com/opennota/check v0.0.0-20180911053232-0c771f5545ff h1:lRHufowVGvUvxGsPveAZOpSa/9T5Gpxg6d7UbHCA9MQ= -github.com/opennota/check v0.0.0-20180911053232-0c771f5545ff/go.mod h1:tydB+MZxWpY8M/NRu7jQhND/mXuLAPsKcSV6JkzofsA= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/ryanuber/go-glob v0.0.0-20170128012129-256dc444b735 h1:7YvPJVmEeFHR1Tj9sZEYsmarJEQfMVYpd/Vyy/A8dqE= -github.com/ryanuber/go-glob v0.0.0-20170128012129-256dc444b735/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= -github.com/securego/gosec v0.0.0-20181111085728-2695567487c0 h1:lQnFFWH0BosPOMqivCFOcFkya9vkVAN2aEeoPLppZEo= -github.com/securego/gosec v0.0.0-20181111085728-2695567487c0/go.mod h1:m3KbCTwh9vLhm6AKBjE+ALesKilKcQHezI1uVOti0Ks= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stripe/safesql v0.0.0-20171221195208-cddf355596fe h1:g2/0xqQnO8Hnl8dN3/Z9XSeeaM7oKhKXktegZPELyRs= -github.com/stripe/safesql v0.0.0-20171221195208-cddf355596fe/go.mod h1:q7b2n0JmzM1mVGfcYpanfVb2j23cXZeWFxcILPn3JV4= -github.com/tsenart/deadcode v0.0.0-20160724212837-210d2dc333e9 h1:vY5WqiEon0ZSTGM3ayVVi+twaHKHDFUVloaQ/wug9/c= -github.com/tsenart/deadcode v0.0.0-20160724212837-210d2dc333e9/go.mod h1:q+QjxYvZ+fpjMXqs+XEriussHjSYqeXVnAdSV1tkMYk= -github.com/walle/lll v0.0.0-20160702150637-8b13b3fbf731 h1:b7JCW5NchRssZBlI5RffUjBWLNEYQg8g2PwVBZSdCsg= -github.com/walle/lll v0.0.0-20160702150637-8b13b3fbf731/go.mod h1:OjXnoVXDAiJx16YuOKsfCCcyNAFO+fj/Ocwtvh0K5SU= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3 h1:x/bBzNauLQAlE3fLku/xy92Y8QwKX5HZymrMz2IiKFc= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/net v0.0.0-20170915142106-8351a756f30f/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20171026204733-164713f0dfce/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/text v0.0.0-20170915090833-1cbadb444a80 h1:LMxnNSL1jel8frQKy+gjCcwcgLsd3UEDVGg9DD8ryxw= -golang.org/x/text v0.0.0-20170915090833-1cbadb444a80/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20170915040203-e531a2a1c15f/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181201035826-d0ca3933b724 h1:eV9myT/I6o1p8salzgZ0f1pz54PEgUf2NkCxEf6t+xs= -golang.org/x/tools v0.0.0-20181201035826-d0ca3933b724/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7 h1:+t9dhfO+GNOIGJof6kPOAenx7YgrZMTdRPV+EsnPabk= -gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= -honnef.co/go/tools v0.0.0-20180920025451-e3ad64cb4ed3 h1:LyX67rVB0kBUFoROrQfzKwdrYLH1cRzHibxdJW85J1c= -honnef.co/go/tools v0.0.0-20180920025451-e3ad64cb4ed3/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed h1:WX1yoOaKQfddO/mLzdV4wptyWgoH/6hwLs7QHTixo0I= -mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= -mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b h1:DxJ5nJdkhDlLok9K6qO+5290kphDJbHOQO1DFFFTeBo= -mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= -mvdan.cc/unparam v0.0.0-20181201214637-68701730a1d7 h1:AHc3hAmhXTHwSA40I4CJW2w2iirqwLzZuFgC6LdbtJk= -mvdan.cc/unparam v0.0.0-20181201214637-68701730a1d7/go.mod h1:N4YHaPPCFjRU1vNrla2C9eoyqLxMaHmrsI8Th4iuQMY= diff --git a/main.go b/main.go index 1118b7cb45377165379af35b21adaf0b406d7b3c..6d5cf2d8b38d2bf99fc79127a4c2da5dad682f5a 100644 --- a/main.go +++ b/main.go @@ -36,25 +36,25 @@ func main() { partnerListingsFile = path.Join(*dataPath, "listings.toml") err := loadListings(structs.NewPartnerMap, &partnerListings, partnerListingsFile) if err != nil { - panic(err) + log.Fatal(err) } swapListingsFile = path.Join(*dataPath, "tut_swaps.toml") err = loadListings(structs.NewSwapMap, &swapListings, swapListingsFile) if err != nil { - panic(err) + log.Fatal(err) } emailConfigPath := path.Join(*dataPath, "email_conf.toml") err = mail.LoadConfig(emailConfigPath) if err != nil { - panic(err) + log.Fatal(err) } confirmationsPath = path.Join(*dataPath, "confirmations.toml") err = loadConfirmations(confirmationsPath) if err != nil { - panic(err) + log.Fatal(err) } backup(path.Join(*dataPath, "/backups/")) @@ -66,24 +66,24 @@ func main() { case <-clearTicker.C: err := clearOldListings(&partnerListings) if err != nil { - panic(err) + log.Fatal(err) } err = clearOldListings(&swapListings) if err != nil { - panic(err) + log.Fatal(err) } } } }() err = clearOldListings(&partnerListings) if err != nil { - panic(err) + log.Fatal(err) } err = clearOldListings(&swapListings) if err != nil { - panic(err) + log.Fatal(err) } registerAll()