"A"
A
"ACGT"
ACGT
st := "ACGT"
len(st)
4
""
len("")
0
import "math/rand"
st = "ACGT"
string(st[rand.Intn(len(st))]) // generating a random nucleotide
C
string(st[rand.Intn(len(st))]) // repeated invocations might yield different nucleotides
T
string(st[rand.Intn(len(st))]) // repeated invocations might yield different nucleotides
T
string(st[rand.Intn(len(st))]) // repeated invocations might yield different nucleotides
T
string(st[rand.Intn(len(st))]) // repeated invocations might yield different nucleotides
C
// make random nucleotide string by concatenating random nucleotides
import "bytes"
var b bytes.Buffer
for i := 0; i < 40; i++ {
b.WriteByte(st[rand.Intn(len(st))])
}
st = b.String()
st
GCAAAGTGCAGTCCGTGAGTTTAGTCATTCACTCGCGGTC
st[1:3] // substring, starting at position 1 and extending up to but not including position 3
// note that the first position is numbered 0
CA
st[0:3] // prefix of length 3
GCA
st[:3] // another way of getting the prefix of length 3
GCA
st[len(st)-3:len(st)] // suffix of length 3
GTC
st[-3:] // another way of getting the suffix of length 3
repl.go:1:5: negative slice index: -3 == Expr{Type: int, Value: -3}
st1, st2 := "CAT", "ATAC"
st1
CAT
st2
ATAC
st1 + st2 // concatenation of 2 strings
CATATAC