Declared but not used

It is a compiler error in Go to declare a variable without using it.

In the code in you’re example the variable partial is never used, only assigned, so is seen as unused. If you added additional code that read the variable then the error would be resolved. For example

var partial string

for i, request := range requestVec {
    if i == (len(requestVec)-1) && !strings.Contains(request, "\r\n\r\n") {
        partial = request

fmt.Println(partial) // We are now using `partial`

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top