Interactive help: Difference between revisions

Added Go
(→‎{{header|Perl 6}}: Add a Perl 6 example)
(Added Go)
Line 5:
This can be for exploring features or syntax, or perhaps a simple message on where to find more information.
<br><br>
 
=={{header|Go}}==
The 'go doc' command line tool shows documentation for either a package or a symbol within a package.
 
For example, here we list the exported functions and types in the 'strings' package in the standard library:
<pre>
$ go doc strings
package strings // import "strings"
 
Package strings implements simple functions to manipulate UTF-8 encoded
strings.
 
For information about UTF-8 strings in Go, see
https://blog.golang.org/strings.
 
func Compare(a, b string) int
func Contains(s, substr string) bool
func ContainsAny(s, chars string) bool
func ContainsRune(s string, r rune) bool
func Count(s, substr string) int
func EqualFold(s, t string) bool
func Fields(s string) []string
func FieldsFunc(s string, f func(rune) bool) []string
func HasPrefix(s, prefix string) bool
func HasSuffix(s, suffix string) bool
func Index(s, substr string) int
func IndexAny(s, chars string) int
func IndexByte(s string, c byte) int
func IndexFunc(s string, f func(rune) bool) int
func IndexRune(s string, r rune) int
func Join(a []string, sep string) string
func LastIndex(s, substr string) int
func LastIndexAny(s, chars string) int
func LastIndexByte(s string, c byte) int
func LastIndexFunc(s string, f func(rune) bool) int
func Map(mapping func(rune) rune, s string) string
func Repeat(s string, count int) string
func Replace(s, old, new string, n int) string
func Split(s, sep string) []string
func SplitAfter(s, sep string) []string
func SplitAfterN(s, sep string, n int) []string
func SplitN(s, sep string, n int) []string
func Title(s string) string
func ToLower(s string) string
func ToLowerSpecial(c unicode.SpecialCase, s string) string
func ToTitle(s string) string
func ToTitleSpecial(c unicode.SpecialCase, s string) string
func ToUpper(s string) string
func ToUpperSpecial(c unicode.SpecialCase, s string) string
func Trim(s string, cutset string) string
func TrimFunc(s string, f func(rune) bool) string
func TrimLeft(s string, cutset string) string
func TrimLeftFunc(s string, f func(rune) bool) string
func TrimPrefix(s, prefix string) string
func TrimRight(s string, cutset string) string
func TrimRightFunc(s string, f func(rune) bool) string
func TrimSpace(s string) string
func TrimSuffix(s, suffix string) string
type Builder struct{ ... }
type Reader struct{ ... }
func NewReader(s string) *Reader
type Replacer struct{ ... }
func NewReplacer(oldnew ...string) *Replacer
 
BUG: The rule Title uses for word boundaries does not handle Unicode punctuation properly.
</pre>
We can now 'dig down' to obtain the documentation for the TrimSpace function wthin the strings package:
<pre>
$ go doc strings.TrimSpace
func TrimSpace(s string) string
TrimSpace returns a slice of the string s, with all leading and trailing
white space removed, as defined by Unicode.
</pre>
and to list the methods of the strings.Replacer struct:
<pre>
$ go doc strings.Replacer
type Replacer struct {
// Has unexported fields.
}
Replacer replaces a list of strings with replacements. It is safe for
concurrent use by multiple goroutines.
 
 
func NewReplacer(oldnew ...string) *Replacer
func (r *Replacer) Replace(s string) string
func (r *Replacer) WriteString(w io.Writer, s string) (n int, err error)
</pre>
Finally, we obtain the documentation for the strings.Replacer.WriteString method:
<pre>
$ go doc strings.Replacer.WriteString
func (r *Replacer) WriteString(w io.Writer, s string) (n int, err error)
WriteString writes s to w with all replacements performed.
</pre>
The 'go doc' tool also has some flags including a flag to list both exported and unexported symbols (-u) and to respect case when matching symbols (-c); normally lower- case letters match either case.
 
=={{header|Jsish}}==
9,485

edits