compiler: truncate output files before writing
Этот коммит содержится в:
родитель
35fe24981f
коммит
a25e598463
2 изменённых файлов: 2 добавлений и 2 удалений
|
@ -3180,7 +3180,7 @@ func (c *Compiler) EmitText(path string) error {
|
||||||
// Write the data to the file specified by path.
|
// Write the data to the file specified by path.
|
||||||
func (c *Compiler) writeFile(data []byte, path string) error {
|
func (c *Compiler) writeFile(data []byte, path string) error {
|
||||||
// Write output to file
|
// Write output to file
|
||||||
f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0666)
|
f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
2
main.go
2
main.go
|
@ -114,7 +114,7 @@ func Build(pkgName, outpath, target string, printIR, dumpSSA bool) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer inf.Close()
|
defer inf.Close()
|
||||||
outf, err := os.OpenFile(outpath, os.O_RDWR|os.O_CREATE, 0777)
|
outf, err := os.OpenFile(outpath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0777)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче