GoLang String

  • date 29th May, 2021 |
  • by Prwatech |
  • 0 Comments

String is a sequence of characters.

Use Case 1:

package main

import (

            “fmt”

            “reflect”

)

var s string = “Hello World”

funcmain() {

            fmt.Println(s)

            fmt.Println(reflect.TypeOf(s))

}

Output:

Use Case 2:

package main

import (

            “fmt”

            “strings”

)

funcmain() {

            s := “Hello World”

            fmt.Println(strings.HasSuffix(s, “IA”))

}

Output:

Use Case 3:

package main

import (

            “fmt”

            “strings”

)

funcmain() {

            var str = “Hi “

            fmt.Println(strings.Repeat(str, 4))

}

Output:

Quick Support

image image