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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:05:57+00:00 2026-05-15T18:05:57+00:00

i have this snippet of code that use an iterator on a list for

  • 0

i have this snippet of code that use an iterator on a list

for x:= range s.faces.Iter(){
    x.Render()
}

as the compiler points, x is of type interface{} and there isn’t a method (i interface)Render() defined in my code.

changing to

for x:= range s.faces.Iter(){
    x.(faceTri).Render()
}

compile, because there is a method func (f faceTri) Render()
but upon execution this runtime error is raised:

panic: interface conversion: interface is *geometry.faceTri, not geometry.faceTri

(geometry is the package)

so, anybody can point me to a resource that explain the go way to use iterators + casting?

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

    That’s actually called a type assertion in go, not a cast (casts are compile time conversions between certain compatible type, i.e. int -> int32).

    Based on the error you posted, you just have a tiny mistake in your code. The underlying type of x is *faceTri (a pointer to a faceTri structure), so the type assertion should be x.(*faceTri)

    EDIT:

    A few things to clarify and go beyond your question. A type assertion in go is not a cast, for example: interface_with_underlying_type_int.(int64) will panic, even though int can be cast to int64

    Also, you can check a type assertion using the comma-ok idiom

    not_interface, ok := some_interface.(some_type)

    ok is a boolean indicating whether the conversion was successful, instead of causing a runtime panic.

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

Sidebar

Related Questions

gcc 4.4.2 c89 I have this code snippet that I have to repeat in
I have the following snippet of code that's generating the Use new keyword if
I have this code in jQuery, that I want to reimplement with the prototype
I have this code snippets that generates a signature for POSTs. The detail of
I have this code snippet: <div id=div1> </div> <div id=div2> <h3>This is the content</h3>
In my views.py, i have a snippit of code like this: def clean_post_data(form): for
I have this RewriteRule that works too well :-) RewriteRule ^([^/]*)/$ /script.html?id=$1 [L] The
I have the following code snippet. I am compiling using the sun studio 12
I have replicated a stripped-down version of my code that has recently been re-written
Ok so, i have this site that i am putting together in the play

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.