]> Cypherpunks.ru repositories - gostls13.git/blob - test/winbatch.go
build: force all Windows batch files to CRLF
[gostls13.git] / test / winbatch.go
1 // run
2
3 // Copyright 2020 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
6
7 // Check that batch files are maintained as CRLF files (consistent behaviour
8 // on all operating systems). See https://github.com/golang/go/issues/37791
9
10 package main
11
12 import (
13         "bytes"
14         "fmt"
15         "io/ioutil"
16         "os"
17         "path/filepath"
18         "runtime"
19 )
20
21 func main() {
22         batches, _ := filepath.Glob(runtime.GOROOT() + "/src/*.bat")
23         for _, bat := range batches {
24                 body, _ := ioutil.ReadFile(bat)
25                 if !bytes.Contains(body, []byte("\r\n")) {
26                         fmt.Printf("Windows batch file %s does not contain CRLF line termination.\nTry running git checkout src/*.bat to fix this.\n", bat)
27                         os.Exit(1)
28                 }
29         }
30 }