Thanks all for your help.
I got it to work like this:
package main

import "fmt"

var ( 
iWork int
sWork string
)
func main() {
theStr := 
"ASDSFHHTBBKLKKJHHDFGHJKHHHJHHKJKJJKJKsdkejffkjf43889934ythbnv3ouy4ti3ykfjjvwkjhfwiuiu4ui4uiyruuhfufuiwefhfwekllllllfe34t3gphrepgqhg38po3hgvnfh38t98ohgerqoi084rt3ukovpklmnfvb
 
[gj po 5hop p6iy 904254uy 45uy 45iuuy 45uy 24u209386 34tu 09y0 5u5ty9025y  
59u934tp33tgprg nbnvkoiojh1234567iklr,fcv7ytgvb rgb 
98uhbrtghnoikjnrfgvyhntghbuik,rfvokmrtg9iuj5rtfychntf8cihjng vf8ihjngvfi 
hnb jikjgdfkjverohgvoreihjgolerkgoehvve rlkvoijinvn 
o4erugoerutjblkgfbkdjfnveorijgve;djvboerijvbofdn"
iRegister2 := make([]uint64, 1000, 10000)
sRegister2 := make([]string, 1000, 10000)
iRegister4 := make([]uint64, 1000, 10000)
sRegister4 := make([]string, 1000, 10000)
iRegister8 := make([]uint64, 1000, 10000)
sRegister8 := make([]string, 1000, 10000)
iRegister16 := make([]uint64, 1000, 10000)
sRegister16 := make([]string, 1000, 10000)
iRegister32 := make([]uint64, 1000, 10000)
sRegister32 := make([]string, 1000, 10000)
iRegister64 := make([]uint64, 1000, 10000)
sRegister64 := make([]string, 1000, 10000)
 
for iWork = 1; iWork <= len(theStr); iWork = iWork + 2{
if (iWork + 1) < len(theStr){
sWork = theStr[iWork - 1:iWork + 1]
inx(&sWork, &iRegister2, &sRegister2)
}
if ((iWork + 3) < len(theStr) && (iWork + 3) % 4 == 0){
sWork = theStr[iWork - 1:iWork + 3]
inx(&sWork, &iRegister4, &sRegister4)
}
if ((iWork + 7) < len(theStr) && (iWork + 7) % 8 == 0){
sWork = theStr[iWork - 1:iWork + 7]
inx(&sWork, &iRegister8, &sRegister8)
}
if ((iWork + 15) < len(theStr) && (iWork + 15) % 16 == 0){
sWork = theStr[iWork - 1:iWork + 15]
inx(&sWork, &iRegister16, &sRegister16)
}
if ((iWork + 31) < len(theStr) && (iWork + 31) % 32 == 0){
sWork = theStr[iWork - 1:iWork + 31]
inx(&sWork, &iRegister32, &sRegister32)
}
if ((iWork + 63) < len(theStr) && (iWork + 63) % 64 == 0){
sWork = theStr[iWork - 1:iWork + 63]
inx(&sWork, &iRegister64, &sRegister64)
} 
} 
}
func inx(s *string, ir *[]uint64, sr *[]string){
var i int
fmt.Printf("The Value is : %s", *s)
for i = 0; ((*ir)[i] != 0 && (*sr)[i] != *s); i++ {
}
if (*sr)[i] != *s {
(*sr)[i] = *s
}
(*ir)[i]++
fmt.Printf("%s = %d\n", *s, (*ir)[i])
}

On Saturday, May 30, 2020 at 9:43:29 PM UTC+2, Silver 7331 wrote:
>
> I'm 1 day old in this wonderful language and trying my best to learn.
> When I try to build the below code I get the following error/s
>
> ./prog.go:66:6: missing function body
> ./prog.go:66:30: syntax error: unexpected [, expecting comma or )
> ./prog.go:69:2: syntax error: non-declaration statement outside function body
> Go build failed.
>
> I figure it must have something to do with the pointer to the string in the 
> function inx, more specifically sr *string[1000]
>
>
> Thanks in advance.
>
>
> code:
> package main
>
> import "fmt"
>
>
> func main() {
> theStr := 
> "ASDSFHHTBBKLKKJHHDFGHJKHHHJHHKJKJJKJKsdkejffkjf43889934ythbnv3ouy4ti3ykfjjvwkjhfwiuiu4ui4uiyruuhfufuiwefhfwekllllllfe34t3gphrepgqhg38po3hgvnfh38t98ohgerqoi084rt3ukovpklmnfvb
>  
> [gj po 5hop p6iy 904254uy 45uy 45iuuy 45uy 24u209386 34tu 09y0 5u5ty9025y  
> 59u934tp33tgprg nbnvkoiojh1234567iklr,fcv7ytgvb rgb 
> 98uhbrtghnoikjnrfgvyhntghbuik,rfvokmrtg9iuj5rtfychntf8cihjng vf8ihjngvfi 
> hnb jikjgdfkjverohgvoreihjgolerkgoehvve rlkvoijinvn 
> o4erugoerutjblkgfbkdjfnveorijgve;djvboerijvbofdn"
>  
> var ( 
> iWork int
> sWork string
> iRegister2[1000] uint64
> iRegister4[1000] uint64
> iRegister8[1000] uint64
> iRegister16[1000] uint64
> iRegister32[1000] uint64
> iRegister64[1000] uint64
> sRegister2[1000][2] string
> sRegister4[1000][4] string
> sRegister8[1000][8] string
> sRegister16[1000][16] string
> sRegister32[1000][32] string
> sRegister64[1000][64] string
> iInx2 uint32
> iInx4 uint32
> iInx8 uint32
> iInx16 uint32
> iInx32 uint32
> iInx64 uint32
> )
> iWork = 0
> for iWork = 0; iWork < len(theStr); iWork = iWork + 2{
> if (iWork + 2) < len(theStr){
> sWork = theStr[iWork:iWork + 1]
> inx(sWork, &sRegister2, &iRegister2, &iInx2)
> }
> if (iWork + 4) % 4 == 0 && (iWork + 4) < len(theStr){
> sWork = theStr[iWork:iWork + 3]
> inx(sWork, &sRegister4, &iRegister4, &iInx4)
> }
> if ((iWork + 8) % 8) == 0 && (iWork + 8) < len(theStr){
> sWork = theStr[iWork:iWork + 7]
> inx(sWork, &sRegister8, &iRegister8, &iInx8)
> }
> if ((iWork + 16) % 16) == 0 && (iWork + 16) < len(theStr){
> sWork = theStr[iWork:iWork + 15]
> inx(sWork, &sRegister16, &iRegister16, &iInx16)
> }
> if ((iWork + 32) % 32) == 0 && (iWork + 32) < len(theStr){
> sWork = theStr[iWork:iWork + 31]
> inx(sWork, &sRegister32, &iRegister32, &iInx32)
> } 
> if ((iWork + 64) % 64) == 0 && (iWork + 64) < len(theStr){
> sWork = theStr[iWork:iWork + 63]
> inx(sWork, &sRegister64, &iRegister64, &iInx64)
> } 
> }
> fmt.Printf("2 char array = %d\n", iInx2)
> fmt.Printf("4 char array = %d\n", iInx4)
> fmt.Printf("8 char array = %d\n", iInx8)
> fmt.Printf("16 char array = %d\n", iInx16)
> fmt.Printf("32 char array = %d\n", iInx32)
> fmt.Printf("64 char array = %d\n", iInx64) 
> }
>
> func inx(s string, sr *string[1000], ir *uint64, ii *uint32) {
> var i int
>
> for i = 0; i < *ii && (*sr)[i] != s; i++ {
> }
> if i >= *ii {
> (*sr)[i] = append((*sr)[i],s)
> *ii = i
> (*ir)[i]++
> }
> }
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/b5892032-08e6-4871-ba3a-cb4627c6739c%40googlegroups.com.

Reply via email to