I'm currently learning Go by doing the rosalind problems (basically a bunch of bioinformatics related code katas).
I'm currently representing a DNA strand with a type:
type DNAStrand struct {
dna byte[]
}
My initial reason was to encapsulate the byte slice so I would know it only contained bytes representing the nucleotides: 'A', 'C', 'G', 'T'. I realized that this was obviously not guarateed since I could simply do:
DNAStrand{[]byte("foo bar")}
And there is no longer any guarantee that my dna strand contains a byte array with only elements from those four bytes.
Since my struct only contains a byte array is it better/more ideomatic to do:
type DNAStrand []byte
Or is it better to let the type contain the dna strand? Are there any rules of thumb for when to use either of the two approaches?