Skip to content
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

I use golang eight years.Today I want create a object.I run the code but I got error. #61245

Closed
epowsal opened this issue Jul 9, 2023 · 1 comment

Comments

@epowsal
Copy link

epowsal commented Jul 9, 2023

I use golang eight years.Today I want create a object.I run the code but I got error.

obj1:={
attributeName1 int
attributeName2 int
AttributeName2 int
init:=func(){

}
Func1:=func()int {
	return 33
}
Func2:=func()int {
	obj3.func1()
	return 3243
}
length float32
go Func1()
obj3:={
	kkk int
	aaa int
	jjj int
	init:=func(){
		
	}
	func1:=func(){
		
	}
	run:=func(){
		
	}
}
obj3.run()	

}

I run it but I got error:
.\RangeTree.go:3:1: syntax error: non-declaration statement outside function body
.\RangeTree.go:7:14: method has no receiver
.\RangeTree.go:7:14: syntax error: unexpected {, expected name
.\RangeTree.go:10:2: syntax error: non-declaration statement outside function body
.\RangeTree.go:10:15: method has no receiver
.\RangeTree.go:11:3: syntax error: unexpected return, expected )
.\RangeTree.go:17:2: syntax error: non-declaration statement outside function body
.\RangeTree.go:23:15: method has no receiver
.\RangeTree.go:23:15: syntax error: unexpected {, expected name
.\RangeTree.go:26:3: syntax error: non-declaration statement outside function body
.\RangeTree.go:26:3: too many errors

I want it no error.
I just want one instance. so didn't need class define.
I want the object have one init func. that initialize the object at define.
I want the object define context can run none define code at object create.eg: obj3.run().

@epowsal epowsal added the pkgsite label Jul 9, 2023
@seankhliao
Copy link
Member

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jul 9, 2023
@golang golang locked and limited conversation to collaborators Jul 8, 2024
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

3 participants