1. Check what is *string[1000]. Maybe you mean *[1000]string 2. Also, it looks like you are passing [1000][2]string etc. to idx, they are of different types. Once you fix that, below are the errors that you get 3. Finally, why use fixed size arrays, that is into idiomatic go. Using slices is.
Enter code here..../test.go:34:15: cannot use &sRegister2 (type *[1000][2] string) as type *[1000]string in argument to inx ./test.go:34:28: cannot use &iRegister2 (type *[1000]uint64) as type *uint64 in argument to inx ./test.go:38:15: cannot use &sRegister4 (type *[1000][4]string) as type *[1000]string in argument to inx ./test.go:38:28: cannot use &iRegister4 (type *[1000]uint64) as type *uint64 in argument to inx ./test.go:42:15: cannot use &sRegister8 (type *[1000][8]string) as type *[1000]string in argument to inx ./test.go:42:28: cannot use &iRegister8 (type *[1000]uint64) as type *uint64 in argument to inx ./test.go:46:15: cannot use &sRegister16 (type *[1000][16]string) as type *[1000]string in argument to inx ./test.go:46:29: cannot use &iRegister16 (type *[1000]uint64) as type *uint64 in argument to inx ./test.go:50:15: cannot use &sRegister32 (type *[1000][32]string) as type *[1000]string in argument to inx ./test.go:50:29: cannot use &iRegister32 (type *[1000]uint64) as type *uint64 in argument to inx On Saturday, May 30, 2020 at 3:43:29 PM UTC-4, 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/0a9a25b4-1da9-408e-b95f-03bb87f01fba%40googlegroups.com.