Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style nits #309

Closed
peterbourgon opened this issue Jan 7, 2020 · 5 comments
Closed

Style nits #309

peterbourgon opened this issue Jan 7, 2020 · 5 comments

Comments

@peterbourgon
Copy link

Nice repo, great attention to detail. Mostly :)

  1. Go file names should be with_underscores.go, e.g. file_system_store.go not FileSystemStore.go
  2. Block comments should be full sentences i.e. include trailing punctuation
@quii
Copy link
Owner

quii commented Jan 30, 2020

Thanks, I'm in general not very detail-oriented and need people to point out my laziness. Will take a look

@quii
Copy link
Owner

quii commented Jan 30, 2020

@peterbourgon Where is this documented? My searches seem to come up with some mixed signals golang/go#36060

@peterbourgon
Copy link
Author

My response in that thread.

@quii
Copy link
Owner

quii commented Jun 18, 2020

No shame here

package main

import (
	"io/ioutil"
	"log"
	"os"
	"path/filepath"
	"strings"
)

func main() {
	path := "."

	err := filepath.Walk(path, func(path string, f os.FileInfo, err error) error {
		if err != nil {
			return err
		}
		if strings.Contains(f.Name(), ".go") && !strings.Contains(path, "vendor") {
			file, err := ioutil.ReadFile(path)
			if err != nil {
				return err
			}

			lines := strings.Split(string(file), "\n")

			for i, line := range lines {
				if strings.HasPrefix(line, `//`) {
					lines[i] = lines[i] + "."
				}
			}
			output := strings.Join(lines, "\n")
			err = ioutil.WriteFile(path, []byte(output), 0644)
			if err != nil {
				return err
			}
		}
		return nil
	})

	if err != nil {
		log.Fatalf("problem opening %q, %v", path, err)
	}
}

@quii quii closed this as completed in bbc3c8a Jun 18, 2020
@peterbourgon
Copy link
Author

Haha brilliant :shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants