From 69cab9d3a1758b4117d8752ef12817270c18d9f6 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Mon, 10 Dec 2018 00:46:23 -0700 Subject: [PATCH] Add CI scripts --- .travis.yml | 23 +++++++++++++++++++++++ README.md | 2 +- appveyor.yml | 31 +++++++++++++++++++++++++++++++ doc_test.go | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 .travis.yml create mode 100644 appveyor.yml create mode 100644 doc_test.go diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..48f38b4 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,23 @@ +language: go + +go: + - 1.x + - tip + +matrix: + allow_failures: + - go: tip + fast_finish: true + +install: + - go get -t ./... + - go get golang.org/x/lint/golint + - go get github.com/alecthomas/gometalinter + +script: + - gometalinter --install + - gometalinter --disable-all -E vet -E gofmt-s -E misspell -E ineffassign -E goimports -E deadcode --tests ./... + - go test -race ./... + +after_script: + - golint ./... diff --git a/README.md b/README.md index 6412991..1753f62 100644 --- a/README.md +++ b/README.md @@ -297,7 +297,7 @@ For example, if you're using the standard library: ```go mux := http.NewServeMux() -mux.Handle("/", func(w http.ResponseWriter, req *http.Request) { +mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { fmt.Fprintf(w, "Lookit my cool website over HTTPS!") }) diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..e2a2cc4 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,31 @@ +version: "{build}" + +clone_folder: c:\gopath\src\github.com\mholt\certmagic + +environment: + GOPATH: c:\gopath + +stack: go 1.11 + +install: + - set PATH=%GOPATH%\bin;%PATH% + - set PATH=C:\msys64\mingw64\bin;%PATH% + - go get -t ./... + - go get golang.org/x/lint/golint + - go get github.com/alecthomas/gometalinter + +build: off + +before_test: + - go version + - go env + +test_script: + - gometalinter --install + - gometalinter --disable-all -E vet -E gofmt-s -E misspell -E ineffassign -E goimports -E deadcode --tests ./... + - go test -race ./... + +after_test: + - golint ./... + +deploy: off diff --git a/doc_test.go b/doc_test.go new file mode 100644 index 0000000..f053fd9 --- /dev/null +++ b/doc_test.go @@ -0,0 +1,35 @@ +// Copyright 2015 Matthew Holt +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package certmagic + +import ( + "fmt" + "log" + "net/http" +) + +// This is the simplest way for HTTP servers to use this package. +// Call HTTPS() with your domain names and your handler (or nil +// for the http.DefaultMux), and CertMagic will do the rest. +func ExampleHTTPS() { + http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { + fmt.Fprintf(w, "Hello, HTTPS visitor!") + }) + + err := HTTPS([]string{"example.com", "www.example.com"}, nil) + if err != nil { + log.Fatal(err) + } +}