On Sat, May 30, 2020 at 12:43 PM Silver 7331 <[email protected]> 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]++
> }
> }


The compiler error message is not the greatest, but the problem is
that you wrote "string[1000]" where you presumably meant to write
"[1000]string".

Ian

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcUsGiMqy5LW%3DShCC96k-QEdoTCF%3D0XMAE5Pa6nKQeRuwg%40mail.gmail.com.

Reply via email to