Skip to content

Commit

Permalink
fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ninedraft committed Oct 2, 2022
1 parent 1586516 commit 88ee83c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
6 changes: 5 additions & 1 deletion cmd/gencert/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,19 @@ func main() {
}

func writePEM(file, name string, data []byte) error {
// #nosec G304 // hardcoded in code
f, errCreate := os.Create(file)
if errCreate != nil {
return fmt.Errorf("creating file: %w", errCreate)
}
defer func() { _ = f.Close() }()

pem.Encode(f, &pem.Block{
errEncode := pem.Encode(f, &pem.Block{
Type: name,
Bytes: data,
})
if errEncode != nil {
return fmt.Errorf("encoding PEM data: %w", errEncode)
}
return nil
}
14 changes: 7 additions & 7 deletions gemax/mime.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ package gemax
//
// Valid values for the "lang" parameter are comma-separated lists of one or
// more language tags as defined in RFC4646. For example:
// * "text/gemini; lang=en" Denotes a text/gemini document written in English
// * "text/gemini; lang=fr" Denotes a text/gemini document written in French
// * "text/gemini; lang=en,fr" Denotes a text/gemini document written in a mixture of English and French
// * "text/gemini; lang=de-CH" Denotes a text/gemini document written in Swiss German
// * "text/gemini; lang=sr-Cyrl" Denotes a text/gemini document written in Serbian using the Cyrllic script
// * "text/gemini; lang=zh-Hans-CN" Denotes a text/gemini document written in Chinese using
// the Simplified script as used in mainland China
// - "text/gemini; lang=en" Denotes a text/gemini document written in English
// - "text/gemini; lang=fr" Denotes a text/gemini document written in French
// - "text/gemini; lang=en,fr" Denotes a text/gemini document written in a mixture of English and French
// - "text/gemini; lang=de-CH" Denotes a text/gemini document written in Swiss German
// - "text/gemini; lang=sr-Cyrl" Denotes a text/gemini document written in Serbian using the Cyrllic script
// - "text/gemini; lang=zh-Hans-CN" Denotes a text/gemini document written in Chinese using
// the Simplified script as used in mainland China
const MIMEGemtext = "text/gemini"
12 changes: 7 additions & 5 deletions gemax/server_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import (
// This mechanism can be used as redirect on other protocol pages.
//
// Examples:
// Redirect(rw, req, "gemini://other.server.com/page", status.Redirect)
// Redirect(rw, req, "../root/page", status.PermanentRedirect)
// Redirect(rw, req, "https://wikipedia.org", status.Success)
//
// Redirect(rw, req, "gemini://other.server.com/page", status.Redirect)
// Redirect(rw, req, "../root/page", status.PermanentRedirect)
// Redirect(rw, req, "https://wikipedia.org", status.Success)
func Redirect(rw ResponseWriter, req IncomingRequest, target string, code status.Code) {
if code == status.Success {
rw.WriteStatus(code, MIMEGemtext)
Expand Down Expand Up @@ -67,8 +68,9 @@ func ServeContent(contentType string, content []byte) Handler {
// Query extracts canonical gemini query values
// from url query part. Values are sorted in ascending order.
// Expected values:
// ?query&key=value => [query]
// ?a&b=&key=value => [a, b]
//
// ?query&key=value => [query]
// ?a&b=&key=value => [a, b]
func Query(query urlpkg.Values) []string {
var keys = make([]string, 0, len(query))
for key, values := range query {
Expand Down
1 change: 1 addition & 0 deletions gemax/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func Text(code Code) string {
}

// Comments copy-pasted from official gemini specification.
//
//go:generate stringer -type Code -linecomment -output status_string.go
const (
// Undefined is a default empty status code value.
Expand Down

0 comments on commit 88ee83c

Please sign in to comment.