Skip to main content

use_go/
lib.rs

1#![forbid(unsafe_code)]
2#![doc = include_str!("../README.md")]
3
4pub mod prelude;
5
6#[cfg(feature = "version")]
7pub mod version {
8    pub use use_go_version::*;
9}
10
11#[cfg(feature = "identifier")]
12pub mod identifier {
13    pub use use_go_identifier::*;
14}
15
16#[cfg(feature = "keyword")]
17pub mod keyword {
18    pub use use_go_keyword::*;
19}
20
21#[cfg(feature = "value")]
22pub mod value {
23    pub use use_go_value::*;
24}
25
26#[cfg(feature = "package")]
27pub mod package {
28    pub use use_go_package::*;
29}
30
31#[cfg(feature = "import")]
32pub mod import {
33    pub use use_go_import::*;
34}
35
36#[cfg(feature = "module")]
37pub mod module {
38    pub use use_go_module::*;
39}
40
41#[cfg(feature = "go-mod")]
42pub mod go_mod {
43    pub use use_go_mod::*;
44}
45
46#[cfg(feature = "go-work")]
47pub mod go_work {
48    pub use use_go_work::*;
49}
50
51#[cfg(feature = "test")]
52pub mod test {
53    pub use use_go_test::*;
54}
55
56#[cfg(feature = "identifier")]
57pub use use_go_identifier::*;
58#[cfg(feature = "import")]
59pub use use_go_import::*;
60#[cfg(feature = "keyword")]
61pub use use_go_keyword::*;
62#[cfg(feature = "go-mod")]
63pub use use_go_mod::*;
64#[cfg(feature = "module")]
65pub use use_go_module::*;
66#[cfg(feature = "package")]
67pub use use_go_package::*;
68#[cfg(feature = "test")]
69pub use use_go_test::*;
70#[cfg(feature = "value")]
71pub use use_go_value::*;
72#[cfg(feature = "version")]
73pub use use_go_version::*;
74#[cfg(feature = "go-work")]
75pub use use_go_work::*;
76
77#[cfg(all(test, feature = "full"))]
78mod tests {
79    use super::{
80        GoIdentifier, GoImportPath, GoKeyword, GoModConfigFile, GoModulePath, GoPackageName,
81        GoPrimitiveValue, GoTestName, GoVersion, GoWorkConfigFile,
82    };
83
84    #[test]
85    fn facade_reexports_every_child_crate() -> Result<(), Box<dyn std::error::Error>> {
86        let version: GoVersion = "1.22".parse()?;
87        let identifier = GoIdentifier::new("ServeHTTP")?;
88        let keyword: GoKeyword = "func".parse()?;
89        let value = GoPrimitiveValue::Bool(false);
90        let package = GoPackageName::new("http")?;
91        let import = GoImportPath::new("net/http")?;
92        let module = GoModulePath::new("example.com/project")?;
93        let config: GoModConfigFile = "go.mod".parse()?;
94        let work: GoWorkConfigFile = "go.work".parse()?;
95        let test = GoTestName::new("TestHandler")?;
96
97        assert_eq!(version.major(), 1);
98        assert_eq!(identifier.as_str(), "ServeHTTP");
99        assert_eq!(keyword.to_string(), "func");
100        assert!(value.is_zero_like());
101        assert_eq!(package.as_str(), "http");
102        assert_eq!(import.as_str(), "net/http");
103        assert_eq!(module.as_str(), "example.com/project");
104        assert_eq!(config.to_string(), "go.mod");
105        assert_eq!(work.to_string(), "go.work");
106        assert_eq!(test.as_str(), "TestHandler");
107        Ok(())
108    }
109}