“Golang Slice String” Réponses codées

Golang Slice String

First of all, you should really read about strings, bytes and runes in Go.

And here is how you can achieve what you want: Go playground (I was not able to properly paste arabic symbols, but if Chinese works, arabic should work too).

    s := "abcdefghijklmnop" 
    fmt.Println(s[2:9]) 

    s = "something which is display"
    fmt.Println(string([]rune(s)[2:9]))
Santino

Golang convertit la tranche en chaîne

Golang program that converts slice to string

package main

import (
    "fmt"
    "strings"
)

func main() {
    // Slice of 3 strings.
    values := []string{"fish", "chicken", "lettuce"}
    // Convert slice into a string.
    result := strings.Join(values, ",");
    fmt.Println(result)
}

Output

fish,chicken,lettuce
Grumpy Giraffe

Réponses similaires à “Golang Slice String”

Questions similaires à “Golang Slice String”

Plus de réponses similaires à “Golang Slice String” dans Go

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code