Skip to content

Private/public struct members in non-Latin languages #37731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kstenerud opened this issue Mar 7, 2020 · 2 comments
Closed

Private/public struct members in non-Latin languages #37731

kstenerud opened this issue Mar 7, 2020 · 2 comments

Comments

@kstenerud
Copy link

kstenerud commented Mar 7, 2020

How do you specify whether a struct field is exported or not when the field names are in a non-Latin language that doesn't have the concept of uppercase and lowercase?

For example:

export/inner/inner.go:

package inner

type X struct {
	名前 string // How do I change the visibility?
}

func NewX(名前 string) *X {
	return &X{名前: 名前}
}

export/main.go:

package main

import (
	"export/inner"
	"fmt"
)

func main() {
	v := inner.NewX("長島")

	// ./main.go:12:46: v.名前 undefined (cannot refer to unexported field or method 名前)
	fmt.Printf("こんにちは、%vさん\n", v.名前)
}
@mattn
Copy link
Member

mattn commented Mar 7, 2020

Probably this is the same topic as #5763

@ALTree
Copy link
Member

ALTree commented Mar 7, 2020

As @mattn said, this is #5763, and also #22188 for the search for a solution to this issue. Regarding your question, what it's usually done is to put an upper-case latin letter at the beginning of the name to export it.

Closing here as a question (which was answered) and a dup of #22188 (for a solution).

@ALTree ALTree closed this as completed Mar 7, 2020
@golang golang locked and limited conversation to collaborators Mar 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants