Skip to main content
replace(str, substr, replace) returns a copy of str with every occurrence of substr replaced by replace.

Signature

Example

Convert a Go module path to a filesystem-safe artifact name by replacing slashes with hyphens:
github.com/myorg/myapp becomes github.com-myorg-myapp-1.0.0.tar.gz.

Notes

  • replace replaces all occurrences. There is no option to replace only the first match.
  • For pattern-based replacement, use regexreplace.