LoginSignup
3
3

More than 5 years have passed since last update.

[Go]文字列のスライスをやっつけで比較する

Posted at

Goで文字列のスライスを比較する必要があったときにやっつけで下のようにやった。

import (
    "fmt"
    "strings"
)

var a, b []string

if strings.Join(a, "/") == strings.Join(b, "/") {
    fmt.Println("Match")
} else {
    fmt.Println("NOT match")
}

セパレータが"\n"とかの方がもうちょっと汎用性があるかな。いい手があったら教えてください。

3
3
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3