fmt: always use import() syntax
parent
ec10831318
commit
211275ab49
|
@ -98,17 +98,18 @@ fn (f mut Fmt) mod(mod ast.Module) {
|
|||
}
|
||||
|
||||
fn (f mut Fmt) imports(imports []ast.Import) {
|
||||
if f.did_imports {
|
||||
if f.did_imports || imports.len == 0 {
|
||||
return
|
||||
}
|
||||
f.did_imports = true
|
||||
// f.import_pos = f.out.len
|
||||
f.did_imports = true
|
||||
/*
|
||||
if imports.len == 1 {
|
||||
imp_stmt_str := f.imp_stmt_str(imports[0])
|
||||
f.out_imports.writeln('import ${imp_stmt_str}\n')
|
||||
} else if imports.len > 1 {
|
||||
*/
|
||||
f.out_imports.writeln('import (')
|
||||
// f.indent++
|
||||
for imp in imports {
|
||||
if !(imp.mod in f.used_imports) {
|
||||
// TODO bring back once only unused imports are removed
|
||||
|
@ -117,9 +118,8 @@ fn (f mut Fmt) imports(imports []ast.Import) {
|
|||
f.out_imports.write('\t')
|
||||
f.out_imports.writeln(f.imp_stmt_str(imp))
|
||||
}
|
||||
// f.indent--
|
||||
f.out_imports.writeln(')\n')
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
fn (f Fmt) imp_stmt_str(imp ast.Import) string {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import os
|
||||
import (
|
||||
os
|
||||
)
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import time
|
||||
import (
|
||||
time
|
||||
)
|
||||
|
||||
fn main() {
|
||||
println(time.now())
|
||||
|
|
Loading…
Reference in New Issue