Documentation
¶
Index ¶
- func AddCode(edit *goedit.Edit, pos token.Pos, code string)
- func AddCodeAfterImports(code string, beginMark string, endMark string, contents []string) stringdeprecated
- func AddContentAfter(content string, beginMark string, endMark string, seq []string, ...) stringdeprecated
- func AddContentBefore(content string, beginMark string, endMark string, seq []string, ...) stringdeprecated
- func AddImport(edit *goedit.Edit, file *ast.File, name string, pkgPath string)
- func Append(edit *goedit.Edit, file *ast.File, s string)
- func CleanPatch(content string) string
- func CleanPatchMarkers(content string, start PatchMarker, end PatchMarker) string
- func EditFile(file string, callback func(content string) (string, error)) (err error)
- func FmtLineDirective(srcFile string, line int) string
- func GetFuncInsertPosition(file *ast.File) token.Pos
- func RemoveBuildIgnore(content string) (string, error)
- func RemoveMarker(content string, marker string) (string, error)
- func ReplaceContentAfter(content string, beginMark string, endMark string, seq []string, target string, ...) string
- func UpdateContent(content string, beginMark string, endMark string, seq []string, i int, ...) string
- func UpdateContentLines(content string, beginMark string, endMark string, seq []string, i int, ...) string
- type FilePath
- type PatchMarker
- type UpdatePosition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanPatch ¶
CleanPatch removes all content between /*<begin and /*<end markers
func CleanPatchMarkers ¶
func CleanPatchMarkers(content string, start PatchMarker, end PatchMarker) string
func FmtLineDirective ¶
for line directive, check https://github.com/golang/go/blob/24b395119b4df7f16915b9f01a6aded647b79bbd/src/cmd/compile/doc.go#L171 this tells the compiler, next line's line number is `line`
func GetFuncInsertPosition ¶
NOTE: new func is always inserted after a position because a function or variable may have some special directive like go:embed, go:linkname... we cannot add anything before them.
func RemoveBuildIgnore ¶
func ReplaceContentAfter ¶
func UpdateContent ¶
func UpdateContentLines ¶
func UpdateContentLines(content string, beginMark string, endMark string, seq []string, i int, position UpdatePosition, addContent string) string
UpdateContentLines add content before or after the `i`'s anchor in `seq` two lines will be automatically added after `beginMark`, and before `endMark`, so you don't need to include a line in `addContent`
Types ¶
type PatchMarker ¶
type UpdatePosition ¶
type UpdatePosition int
const ( UpdatePosition_After UpdatePosition = 0 UpdatePosition_Before UpdatePosition = 1 UpdatePosition_Replace UpdatePosition = 2 )
Click to show internal directories.
Click to hide internal directories.