fmt: align consts

pull/4304/head
ka-weihe 2020-04-09 01:10:08 +02:00 committed by GitHub
parent 77d41d03f5
commit 71190c27a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View File

@ -179,10 +179,18 @@ fn (f mut Fmt) stmt(node ast.Stmt) {
f.write('pub ')
}
f.writeln('const (')
mut max := 0
for field in it.fields {
if field.name.len > max {
max = field.name.len
}
}
f.indent++
for i, field in it.fields {
name := field.name.after('.')
f.write('$name = ')
f.write('$name ')
f.write(strings.repeat(` `, max - field.name.len))
f.write('= ')
f.expr(field.expr)
f.writeln('')
}

View File

@ -1,5 +1,7 @@
const (
pi = 3.14
pi = 3.14
phi = 1.618
eulers = 2.7182
)
pub const (

View File

@ -1,5 +1,7 @@
const (
pi=3.14
phi=1.618
eulers=2.7182
)
pub const (