Skip to content

Instantly share code, notes, and snippets.

@yamamoto-febc
Last active October 13, 2016 01:51
Show Gist options
  • Save yamamoto-febc/b2bb078e5f93f5599bb508b624ae658f to your computer and use it in GitHub Desktop.
Save yamamoto-febc/b2bb078e5f93f5599bb508b624ae658f to your computer and use it in GitHub Desktop.
goでのgodoc用コメント作成 正規表現 ref: http://qiita.com/yamamoto-febc/items/c3c874095a3714ff4633
#!/bin/sh
perl -i -pe 's/^type\s*([A-Z][\w]*)/\/\/ $1 \n$&/g' $1
perl -i -pe 's/^func\s*([A-Z][\w]*)/\/\/ $1 \n$&/g' $1
perl -i -pe 's/^func\s*\(\w*\s*\S*\s*([A-Z][\w]*)/\/\/ $1 \n$&/g' $1
perl -i -pe 's/^(\s*)([A-Z][\w]*)/$1\/\/ $2 \n$&/g' $1
^type\s*([A-Z][\w]*)
^(\s*)([A-Z][\w]*)
$1// $2 \n$0
^func\s*([A-Z][\w]*)
^func\s*\(\w*\s*\S*\s*([A-Z][\w]*)
add_comment_go.sh [対象ファイル]
type Example struct {
Hoge string
Fuga string
*Embedded
}
type Example struct {
// Hoge
Hoge string
// Fuga
Fuga string
*Embedded
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment