mirror of
				https://github.com/XRPLF/clio.git
				synced 2025-11-04 11:55:51 +00:00 
			
		
		
		
	style: Apply go fmt to go code (#2046)
				
					
				
			~I will add pre-commit hook later if I find a good one~ Found a nice repo, but it is no longer maintained: https://github.com/dnephin/pre-commit-golang So, I implemented the check as a local hook.
This commit is contained in:
		@@ -30,3 +30,12 @@ repos:
 | 
			
		||||
    hooks:
 | 
			
		||||
      - id: prettier
 | 
			
		||||
        exclude: ^docs/doxygen-awesome-theme/
 | 
			
		||||
 | 
			
		||||
  - repo: local
 | 
			
		||||
    hooks:
 | 
			
		||||
      - id: gofmt
 | 
			
		||||
        name: Go Format
 | 
			
		||||
        entry: pre-commit-hooks/run-go-fmt.sh
 | 
			
		||||
        types: [go]
 | 
			
		||||
        language: golang
 | 
			
		||||
        description: "Runs `gofmt`, requires golang"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										14
									
								
								pre-commit-hooks/run-go-fmt.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										14
									
								
								pre-commit-hooks/run-go-fmt.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,14 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
#
 | 
			
		||||
# Capture and print stdout, since gofmt doesn't use proper exit codes
 | 
			
		||||
#
 | 
			
		||||
set -e -o pipefail
 | 
			
		||||
 | 
			
		||||
if ! command -v gofmt &> /dev/null ; then
 | 
			
		||||
    echo "gofmt not installed or available in the PATH" >&2
 | 
			
		||||
    exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
output="$(gofmt -l -w "$@")"
 | 
			
		||||
echo "$output"
 | 
			
		||||
[[ -z "$output" ]]
 | 
			
		||||
@@ -4,12 +4,12 @@ import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"github.com/gorilla/websocket"
 | 
			
		||||
	"io"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/url"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"time"
 | 
			
		||||
	"github.com/gorilla/websocket"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type RequestMaker interface {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user