### Go Array/Slice Indexing Example Source: https://github.com/go-lang-plugin-org/go-lang-idea-plugin/blob/master/testData/parser/Torture.txt Demonstrates nested array or slice indexing in Go. This pattern is common when accessing elements within multi-dimensional data structures. ```Go s[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0] ``` -------------------------------- ### Go AST Parsing Example Source: https://github.com/go-lang-plugin-org/go-lang-idea-plugin/blob/master/testData/parser/Torture.txt Illustrates the structure of an Abstract Syntax Tree (AST) for a Go expression involving matrix indexing and multiplication. This is useful for understanding how Go code is represented internally. ```go m[2][0] + m[3][1] ``` ```go m[0][3] * m[1][2] ``` ```go m[2][1] * m[3][0] ``` ```go m[0][3] * m[1][2] ``` ```go m[2][1] * m[3][0] ``` -------------------------------- ### Go Function with Chained Type Assertions Source: https://github.com/go-lang-plugin-org/go-lang-idea-plugin/blob/master/testData/parser/Torture.txt A Go function 'ChainT' that takes a pointer to a 'T' struct and performs a series of nested type assertions. This example illustrates complex type checking and assertion patterns in Go. ```go func ChainT(t *T) *T { return t.(*T) } ``` -------------------------------- ### Go Channel Creation with Capacity Source: https://github.com/go-lang-plugin-org/go-lang-idea-plugin/blob/master/testData/parser/Torture.txt Demonstrates creating a Go channel with a specific capacity using nested `make` and `cap` calls. This pattern is useful for controlling buffer sizes in concurrent programming. ```go func ChainCap() { select { case <-make(chan chan int, cap(make(chan chan int, cap(make(chan chan int, cap(make(chan chan int))))))): } } ``` -------------------------------- ### Bitwise Left Shift and OR Operations on uint64 Slice in Go Source: https://github.com/go-lang-plugin-org/go-lang-idea-plugin/blob/master/testData/parser/Torture.txt This snippet demonstrates bitwise left shift and OR operations on elements of a uint64 slice. It accesses specific elements of the slice 's' and performs these operations. ```Go uint64(s[12]) << 4 | uint64(s[13]) << 4 | uint64(s[14]) << 4 | uint64(s[15]) << 4 ``` -------------------------------- ### Go Chain Multiplication Function Source: https://github.com/go-lang-plugin-org/go-lang-idea-plugin/blob/master/testData/parser/Torture.txt Demonstrates a function that performs chained multiplication and addition operations on byte types. Ensure inputs are within byte limits to avoid overflow. ```go func ChainMulBytes(a, b, c byte) byte { return a * (a * (a * (a * (a * (a * (a * (a * a * b) + c)))))) } ``` -------------------------------- ### Go Function with Deep Indexing Source: https://github.com/go-lang-plugin-org/go-lang-idea-plugin/blob/master/testData/parser/Torture.txt Demonstrates a Go function that returns an integer after performing a deep chain of array/slice indexings on its input. Ensure the input slice has sufficient depth to avoid runtime panics. ```go func IndexChain3(s [][][][][][][][][][][][][][][]int) int { return s[i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i] } ``` -------------------------------- ### Go Function with Chained Indexing Source: https://github.com/go-lang-plugin-org/go-lang-idea-plugin/blob/master/testData/parser/Torture.txt This Go function demonstrates a long chain of indexings on a slice or array 's' using an integer index 'i'. It returns the final accessed element. ```Go func IndexChain2(s A, i int) A { return s[i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i] } ``` -------------------------------- ### Go Function Declaration and Return Source: https://github.com/go-lang-plugin-org/go-lang-idea-plugin/blob/master/testData/parser/Torture.txt Defines a Go function 'ChainDivConst' that takes an integer 'a' and returns an integer. The function body consists of a complex division expression. ```go func ChainDivConst(a int) int { return a / 17 / 17 / 17 / 17 / 17 / 17 / 17 / 17 / 17 / 17 / 17 } ``` -------------------------------- ### Go Function ChainAssertArrayptrIndex Source: https://github.com/go-lang-plugin-org/go-lang-idea-plugin/blob/master/testData/parser/Torture.txt Demonstrates chained type assertions and array indexing on a pointer to an array. This pattern is useful for deeply nested data structures. ```go func ChainAssertArrayptrIndex(u *UArrPtr) J { return u.Children[0].(J) } ``` -------------------------------- ### Accessing Nested Elements in Go Source: https://github.com/go-lang-plugin-org/go-lang-idea-plugin/blob/master/testData/parser/Torture.txt This snippet demonstrates accessing nested elements within a complex data structure, likely involving arrays, slices, and pointers. It shows a chain of property access and indexing. ```Go (*UArr).Children[0].(*UArr).Children[0].(*UArr).Children[0].(*UArr).Children[0].(*UArr).Children[0].(*UArr).Children[0].(*UArr).Children[0].(*UArr).Children[0]} ``` -------------------------------- ### Concatenate Bytes to Uint64 in Go Source: https://github.com/go-lang-plugin-org/go-lang-idea-plugin/blob/master/testData/parser/Torture.txt This function concatenates 16 4-bit integers (bytes) into a single 64-bit unsigned integer. It's useful for packing small data values into a larger type for efficient storage or transmission. ```Go func concat(s *[16]byte) uint64 { r := uint64(0) for _, v := range s { r = (r << 4) | uint64(v) } return r } ``` -------------------------------- ### Go Function with Deep Indexing Source: https://github.com/go-lang-plugin-org/go-lang-idea-plugin/blob/master/testData/parser/Torture.txt Implements a function 'IndexChain1' that returns a deeply nested indexed element of the input slice 's'. This demonstrates complex slicing syntax in Go. ```go func IndexChain1(s A) A { return s[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0] } ``` -------------------------------- ### Go Function Declaration with Type Assertion Source: https://github.com/go-lang-plugin-org/go-lang-idea-plugin/blob/master/testData/parser/Torture.txt Demonstrates a Go function that returns a type assertion on a pointer type. This is useful for type checking and conversion in Go. ```go func ChainUNoAssert(u *U) *U { return u.(U) } ```