github.com/cyverse/go-irodsclient@v0.13.2/README.md (about)

     1  # go-irodsclient
     2  Go iRODS Client implemented in pure Golang
     3  
     4  ## Import package
     5  ```go
     6  import (
     7      "github.com/cyverse/go-irodsclient/fs"
     8      "github.com/cyverse/go-irodsclient/irods/types"
     9      "github.com/cyverse/go-irodsclient/irods/util"
    10  )
    11  ```
    12  
    13  ## Account Configuration YAML
    14  ```yaml
    15  host:
    16    hostname: "data.cyverse.org"
    17    port: 1247
    18  user:
    19    username: "USERNAME"
    20    password: "PASSWORD"
    21    zone: "iplant"
    22  auth_scheme: "native"
    23  ```
    24  
    25  Loading a YAML file.
    26  ```go
    27  yaml, err := os.ReadFile("account.yml")
    28  if err != nil {
    29      logger.Error(err)
    30      panic(err)
    31  }
    32  
    33  account, err := types.CreateIRODSAccountFromYAML(yaml)
    34  if err != nil {
    35      logger.Error(err)
    36      panic(err)
    37  }
    38  ```
    39  
    40  ## FileSystem Interface
    41  Creating a file system object with default configurations.
    42  ```go
    43  appName := "delete_file"
    44  filesystem, err := fs.NewFileSystemWithDefault(account, appName)
    45  if err != nil {
    46      panic(err)
    47  }
    48  defer filesystem.Release()
    49  ```
    50  
    51  Deleting a file and double check the file existance.
    52  ```go
    53  err = filesystem.RemoveFile("/iplant/home/iychoi/test", true) // do it forcefully
    54  if err != nil {
    55      logger.Error(err)
    56      panic(err)
    57  }
    58  
    59  if !filesystem.ExistsFile("/iplant/home/iychoi/test") {
    60      fmt.Printf("Successfully deleted file\n")
    61  } else {
    62      fmt.Printf("Could not delete file\n")
    63  }
    64  ```
    65  
    66  Downloading a file.
    67  ```go
    68  err = filesystem.DownloadFile("/iplant/home/iychoi/test", "", "/opt", nil) // download a file from default resource ("") to /opt local dir
    69  if err != nil {
    70      logger.Error(err)
    71      panic(err)
    72  }
    73  ```
    74  
    75  
    76  More examples can be found in `/examples` directory.
    77  
    78  ## License
    79  
    80  Copyright (c) 2010-2021, The Arizona Board of Regents on behalf of The University of Arizona
    81  
    82  All rights reserved.
    83  
    84  Developed by: CyVerse as a collaboration between participants at BIO5 at The University of Arizona (the primary hosting institution), Cold Spring Harbor Laboratory, The University of Texas at Austin, and individual contributors. Find out more at http://www.cyverse.org/.
    85  
    86  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
    87  
    88   * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    89   * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    90   * Neither the name of CyVerse, BIO5, The University of Arizona, Cold Spring Harbor Laboratory, The University of Texas at Austin, nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission.
    91  
    92  
    93  Please check [LICENSE](https://github.com/cyverse/go-irodsclient/tree/master/LICENSE) file.