Commit bab2d5b1 authored by cui's avatar cui Committed by GitHub

refactor: using slices.Contains (#11521)

parent 01270d2d
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"slices"
"strings" "strings"
) )
...@@ -154,7 +155,7 @@ func docGen(invariantsDir, docsDir string) error { ...@@ -154,7 +155,7 @@ func docGen(invariantsDir, docsDir string) error {
for _, contract := range docs { for _, contract := range docs {
filePath := filepath.Join(docsDir, contract.Name+".md") filePath := filepath.Join(docsDir, contract.Name+".md")
alreadyWritten := contains(writtenFiles, filePath) alreadyWritten := slices.Contains(writtenFiles, filePath)
// If the file has already been written, append the extra docs to the end. // If the file has already been written, append the extra docs to the end.
// Otherwise, write the file from scratch. // Otherwise, write the file from scratch.
...@@ -253,12 +254,3 @@ func renderContractDoc(contract Contract, header bool) string { ...@@ -253,12 +254,3 @@ func renderContractDoc(contract Contract, header bool) string {
return sb.String() return sb.String()
} }
func contains(slice []string, item string) bool {
for _, v := range slice {
if v == item {
return true
}
}
return false
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment