mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Fix files that gofmt can't parse
We have some .go files that gofmt can't parse because they don't start with "package". This was intentional, as they are fragments to be included in .qhelp files. They don't affect the return code as gofmt doesn't change their formatting, so this wasn't changing the result of the check. However, it was confusing that when the check failed because some other files weren't formatted correctly, the user would see the stderr complaining about those files, so we capture stderr. It would be an improvement to print which files are not formatted correctly, but that was beyond my abilities with bash and makefiles.
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
func bad() error {
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func bad() (string, error) {
|
||||
// ...
|
||||
t, err := pam.StartFunc("", "username", func(s pam.Style, msg string) (string, error) {
|
||||
switch s {
|
||||
case pam.PromptEchoOff:
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
func good() error {
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func good() (string, error) {
|
||||
t, err := pam.StartFunc("", "username", func(s pam.Style, msg string) (string, error) {
|
||||
switch s {
|
||||
case pam.PromptEchoOff:
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
mySigningKey := []byte("AllYourBase")
|
||||
package main
|
||||
|
||||
claims := &jwt.RegisteredClaims{
|
||||
ExpiresAt: jwt.NewNumericDate(time.Unix(1516239022, 0)),
|
||||
Issuer: "test",
|
||||
import "time"
|
||||
|
||||
func bad() {
|
||||
mySigningKey := []byte("AllYourBase")
|
||||
|
||||
claims := &jwt.RegisteredClaims{
|
||||
ExpiresAt: jwt.NewNumericDate(time.Unix(1516239022, 0)),
|
||||
Issuer: "test",
|
||||
}
|
||||
|
||||
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
|
||||
ss, err := token.SignedString(mySigningKey)
|
||||
}
|
||||
|
||||
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
|
||||
ss, err := token.SignedString(mySigningKey)
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
"time"
|
||||
)
|
||||
|
||||
func GenerateCryptoString(n int) (string, error) {
|
||||
const chars = "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-"
|
||||
ret := make([]byte, n)
|
||||
@@ -11,13 +18,14 @@ func GenerateCryptoString(n int) (string, error) {
|
||||
return string(ret), nil
|
||||
}
|
||||
|
||||
mySigningKey := GenerateCryptoString(64)
|
||||
func good() {
|
||||
mySigningKey := GenerateCryptoString(64)
|
||||
|
||||
claims := &jwt.RegisteredClaims{
|
||||
ExpiresAt: jwt.NewNumericDate(time.Unix(1516239022, 0)),
|
||||
Issuer: "test",
|
||||
}
|
||||
|
||||
claims := &jwt.RegisteredClaims{
|
||||
ExpiresAt: jwt.NewNumericDate(time.Unix(1516239022, 0)),
|
||||
Issuer: "test",
|
||||
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
|
||||
ss, err := token.SignedString(mySigningKey)
|
||||
}
|
||||
|
||||
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
|
||||
ss, err := token.SignedString(mySigningKey)
|
||||
|
||||
Reference in New Issue
Block a user