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 4085280
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:33:16+00:00 2026-05-20T18:33:16+00:00

Can anyone tell my why this wouldn’t compile? package main type myint int func

  • 0

Can anyone tell my why this wouldn’t compile?

package main

type myint int
func set(a **myint) {
    i := myint(5)
    *a = &i 
}

func main() {
    var k *int
    set( (**myint)(&k) ) // cannot convert &k (type **int) to type **myint
    print( *k )
}

My reasoning so far is this. All types in Golang are different, but it allows to convert from one type to another with C-like cast syntax as long as underlying types are identical. In my example, converting ‘int’ to ‘myint’ is not a problem. ‘*int’ to ‘*myint’ isn’t either. It’s when you have pointer to pointer problems arise. I’ve been stuck on this for the second day now. Any help is appreciated.

  • 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-05-20T18:33:16+00:00Added an answer on May 20, 2026 at 6:33 pm

    Here’s my analysis.

    (**myint)(&k) — cannot convert &k (type **int) to type **myint:

    type **int and type **myint are unnamed pointer types and their pointer base types, type *int and type *myint, don’t have identical underlying types.

    If T (*int or *myint) is a pointer type literal, the corresponding underlying type is T itself.

    (*myint)(k) — can convert k (type *int) to type *myint:

    type *int and type *myint are unnamed pointer types and their pointer base types, type int and type myint (type myint int), have identical underlying types.

    If T (int) is a predeclared type, the corresponding underlying type is T itself. If T (myint) is neither a predeclared type or nor a type literal, T’s underlying type is the underlying type of the type to which T refers in its type declaration (type myint int).

    (myint)(*k) — can convert *k (type int) to type myint:

    type int and type myint have identical underlying types.

    If T (int) is a predeclared type, the corresponding underlying type is T itself. If T (myint) is neither a predeclared type or nor a type literal, T’s underlying type is the underlying type of the type to which T refers in its type declaration (type myint int).

    Here’s the underlying type example from the Types section revised to use integers and int pointers.

    type T1 int
    type T2 T1
    type T3 *T1
    type T4 T3
    

    The underlying type of int, T1, and T2 is int. The underlying type of *T1, T3, and T4 is *T1.

    References:

    The Go Programming Language Specification

    Conversions

    Types

    Properties of types and values

    Type declarations

    Predeclared identifiers

    Pointer Type

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

Sidebar

Related Questions

Can anyone tell me why this wouldn't work on Safari? // Set the height
Can anyone tell me why this would generate a syntax error in Safari and
Can anyone tell me why this code would not be working? $('body').on('test', function() {
Can anyone tell me why this function is not working ? for(var i=1;i<=12;i++) {
can anyone tell me why this does not work Excel.Worksheet ws_res = (Excel.Worksheet) wb.Worksheets.Add(mis,
Can anyone tell me why this bash script works if I cut and paste
can anyone tell me why this code don't work: $q = $_GET['q']; // Load
Can anyone tell me why this isn't working? It always returns false . $str
Can anyone tell me what this message means? AddRunningClient starting device on non-zero client
Can anyone please tell why this error? I have included everything ( all header,

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.