For ciphering and deciphering we need two different functions. Here is the modified program with two functions cipher and decipher:
package main
import "fmt"
import "strings"
func decipher(cipherT string, keyW string) string {
message := ""
for i, _ := range cipherT {
if cipherT[i] >= keyW[i] {
message += string('A' + (cipherT[i]  keyW[i]))
} else {
message += string('Z' + 1 + (cipherT[i]  keyW[i]))
}
}
return message
}
func cipher(plainT string, keyW string) string {
cipherT := ""
for i, _ := range plainT {
if plainT[i] + (keyW[i]'A') <= 'Z' {
cipherT += string(plainT[i] + (keyW[i]'A'))
} else {
cipherT += string(plainT[i] + (keyW[i]'Z'1))
}
}
return cipherT
}
func main() {
cipherText := "CSOITEUIWUIZNSROCNKFD"
keyword := "GOLANG"
s := len(cipherText)
k := len(keyword)
key := strings.Repeat(keyword, s/k) + keyword[:s%k] // key = "GOLANGGOLANGGOLANGGOL" ""
plainText := decipher(cipherText , key)
newCiphertext := cipher(plainText, key)
fmt.Println("ciphertext: ", cipherText )
fmt.Println("original message: ", plainText)
fmt.Println("ciphering of original message: ", newCiphertext)
}
Concerning the condition if cipherText[i] >= key[i]:
In the following I write c[i] for ciphertext[i], m[i] for message[i] and k[i] for key[i].
From the definition of cipher we have either
(1) c[i] = m[i] + k[i]  'A'
or
(2) c[i] = m[i] + k[i]  ('Z'+1).
Further 'A' <= m[i] <= 'Z'.
We have
(1) if and only if c[i]  k[i] = m[i]  'A'
(2) if and only if c[i]  k[i] = m[i]  ('Z'+1)
As m[i] >= 'A' we get: (1) if and only if c[i] >= k[i]
As m[i] <= 'Z' we get: (2) if and only if c[i] < k[i].
Therefore from c[i] >= k[i] we get (1) and therefore we further get m[i] = c[i] + 'A'  k[i].
