I'm facing the error "panic: runtime error: makeslice: len out of range", while creating a dynamic array, for large values of length using "make()".

eg.

arr := make([]int, length)   //length is a dynamic value

I know, this question was already asked here (Maximum length of a slice in Go). But, the make method does not support maximum value of the "int" datatype in golang. They consume the length value based on (size of) struct type. Is there any predefined APIs available to find maximum of the length value of a collection that can be declared in golang ?

Eg:

maxInt := int(^uint(0) >> 1) 

arr := make([]struct{}, maxInt-1)  //accepted
arr := make([]int, maxInt-1)  //throw error