我了解到,目录中的所有.go
个文件都必须命名相同的包。
从github考虑以下example,
fogleman/nes/
nes/
apu.go
cartridge.go
console.go
controller.go
cpu.go
filter.go
ines.go
mapper.go
mapper1.go
mapper2.go
mapper3.go
mapper4.go
mapper7.go
memory.go
palette.go
ppu.go
ui/
util/
.gitignore
LICENSE.md
README.md
main.go
因此,目录(.go
)中的所有../fogleman/nes/nes
文件都具有包名nes
(与目录名相同)。
同样,目录.go
中的所有../fogleman/nes/ui
文件都具有包名ui
(与目录名相同)。
考虑到以下两个文件,我有一个问题,
1)
目录(roms.go
)中的 ../fogleman/nes/util
文件包名为main
(与目录名不同)
2)
目录(main.go
)中的 ../fogleman/nes
文件包main
(与目录名不同)。
问题:
为什么包名称(main
)与其目录名称不同?
答案 0 :(得分:2)
我相信这个回购的作者打算将roms.go作为一个单独的测试程序运行。如果不将此文件放在包cd util
中,则无法完成此操作。如果您位于根项目目录中:
go run roms.go path/to/roms/dir
plotgraph <- function(x, y, colour, min, max)
{
plot1 <- ggplot(dims, aes(x = x, y = y, fill = Region)) +
geom_boxplot()
#plot1 <- plot1 + scale_x_discrete(name = "Blog Type")
plot1 <- plot1 + labs(color='Region') + geom_hline(yintercept = 0, alpha = 0.4)
plot1 <- plot1 + scale_y_continuous(breaks=c(seq(min,max,5)), limits = c(min, max))
plot1 <- plot1 + labs(x="Blog Type", y="Dimension Score") + scale_fill_grey(start = 0.3, end = 0.7) + theme_grey()
plot1 <- plot1 + theme(legend.justification = c(1, 1), legend.position = c(1, 1))
return(plot1)
}
plot1 <- plotgraph (Blog, Dim1, Region, -30, 25)