Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8684157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:13:57+00:00 2026-06-12T22:13:57+00:00

I has encountered an error while implement the below code: package main import (

  • 0

I has encountered an error while implement the below code:

package main

import (
    "fmt" 
)

type Struct struct {
    a int
    b int
}

func Modifier(ptr *Struct, ptrInt *int) int {
    *ptr.a++
    *ptr.b++
    *ptrInt++
    return *ptr.a + *ptr.b + *ptrInt
}

func main() { 
    structure := new(Struct)
    i := 0         
    fmt.Println(Modifier(structure, &i))
}

That gives me an error something about “invalid indirect of ptr.a (type int)…”. And also why the compiler don’t give me error about ptrInt? Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:13:58+00:00Added an answer on June 12, 2026 at 10:13 pm

    Just do

    func Modifier(ptr *Struct, ptrInt *int) int {
        ptr.a++
        ptr.b++
        *ptrInt++
        return ptr.a + ptr.b + *ptrInt
    }
    

    You were in fact trying to apply ++ on *(ptr.a) and ptr.a is an int, not a pointer to an int.

    You could have used (*ptr).a++ but this is not needed as Go automatically solves ptr.a if ptr is a pointer, that’s why you don’t have -> in Go.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Has anyone encountered this error message recently while using FEDEX's shipping rate API?? I've
A .NET project I've worked on, has encountered a build error recently. The project
I've encountered the following error while trying to create a blogging application. Any ideas
I encountered the following error while running rake db:migrate --trace . my rails version
Has anyone encountered this error using SQL Server 2005 and Data access application blocks
I have encountered an error while debugging a VB.Net application in Visual Studio 2008.
My application has encountered a problem and needs to close. Of course Microsoft is
For automated testing reasons I want to detect if the browser has encountered JavaScript
Following this discussion , I've encountered a bad access issue; A loop has several
Has anyone ever used the hidden class PackageParser in Android source code with java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.