INNER CODE UNIT · Go

mustReadAndFormatGoFile

cweill/gotests · gotests_test.go:941

func mustReadAndFormatGoFile(t *testing.T, filename string) string {
	fmted, err := imports.Process(filename, nil, nil)
	if err != nil {
		t.Fatalf("reading and formatting file: %v", err)
	}
	return string(fmted)
}

func outputResult(t *testing.T, tmpDir, testName string, got []byte) {
	tmpResult := path.Join(tmpDir, toSnakeCase(testName)+".go")
	if err := ioutil.WriteFile(tmpResult, got, 0644); err != nil {
		t.Errorf("ioutil.WriteFile: %v", err)
	}
	t.Logf("%s", tmpResult)
}

func loadExternalJsonFile(file string) (map[string]interface{}, error) {
	buf, err := ioutil.ReadFile(file)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…